-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
* 'master' of github.com:seekshreyas/obidroid: concatenate json files moved concat to scripts mergedJson Create concat.py Adding web service capabilities and configuration Updates to sqlalchemy files that communicate with the DB. Updated files to include app developer information
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from sqlalchemy import * | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy.orm import sessionmaker, relationship | ||
from itertools import islice, count | ||
from models.review import Review | ||
from models.app import App | ||
import pdb | ||
|
||
engine = create_engine('postgresql://postgres:[email protected]:28432/obidroid') | ||
engine.echo = True | ||
Base = declarative_base() | ||
Session = sessionmaker(bind=engine) | ||
session = Session() | ||
|
||
|
||
|
||
def get_all_apps(): | ||
return session.query(App).all() | ||
|
||
def get_app_by_appid(appid): | ||
return session.query(App).filter(App.appid==appid).first() | ||
|
||
def get_apps_by_category(category): | ||
return session.query(App).filter(App.category==category).all() | ||
|
||
def get_reviews_by_category(category): | ||
qry = session.query(App, Review).filter(App.category==category) | ||
reviews = qry.filter(App.appid==Review.playappid).all() | ||
return reviews | ||
|
||
def get_reviews_by_appid(appid): | ||
return session.query(Review).filter(Review.playappid==appid).all() | ||
|
||
if __name__ == '__main__': | ||
#main | ||
pass | ||
#app_instance = get_reviews_by_appid('test.luis.app') | ||
#revs = get_reviews_by_category('Test') | ||
#print revs |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
worker_processes 4; | ||
|
||
events {} | ||
|
||
http { | ||
upstream database { | ||
postgres_server 127.0.0.1 dbname=obidroid user=postgres password=i219kkls; | ||
} | ||
|
||
server { | ||
listen 8080; | ||
server_name localhost; | ||
|
||
location /appsByCategory { | ||
postgres_pass database; | ||
rds_json on; | ||
postgres_escape $category $arg_category; | ||
postgres_query "SELECT * FROM app WHERE category=$category"; | ||
postgres_rewrite HEAD GET no_rows 410; | ||
} | ||
|
||
location /reviewByAppId { | ||
postgres_pass database; | ||
rds_json on; | ||
postgres_escape $appid $arg_appid; | ||
postgres_query HEAD GET "SELECT * FROM review WHERE playappid=$appid"; | ||
postgres_rewrite HEAD GET no_rows 410; | ||
} | ||
|
||
location /appByAppId { | ||
postgres_pass database; | ||
rds_json on; | ||
postgres_escape $appid $arg_appid; | ||
postgres_query HEAD GET "SELECT * FROM app WHERE appid=$appid"; | ||
postgres_rewrite HEAD GET no_rows 410; | ||
} | ||
|
||
location /reviewsByCategory { | ||
postgres_pass database; | ||
rds_json on; | ||
postgres_escape $category $arg_category; | ||
postgres_query HEAD GET "SELECT app.appid, review.title, review.review FROM app, review WHERE app.category=$category AND app.appid=review.playappid"; | ||
postgres_rewrite HEAD GET no_rows 410; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import json,os | ||
|
||
#ie mergeAllFiles('/Users/Artemis/Desktop/gpstore') | ||
|
||
def mergeAllFiles(directory): | ||
"""Searches through current directory and merges | ||
the files that contain app info with the corresponding | ||
reviews from the matching "reviews.json" file. | ||
""" | ||
allDirFiles = os.listdir(directory) | ||
for jsonFile in allDirFiles: | ||
if "_all.json" in jsonFile: | ||
reviewFile = jsonFile[:-8] + "reviews.json" | ||
mergeJson(jsonFile,reviewFile,directory) | ||
return | ||
|
||
def mergeJson(allJson,reviewJson,directory): | ||
"""Modifies the json file containing the | ||
main information about the apps to also include | ||
the information contained in the reviews""" | ||
results = [] | ||
|
||
allFile = json.load(open(directory + "/" + allJson)) | ||
reviewFile = json.load(open(directory + "/" + reviewJson)) | ||
|
||
for app in zip(allFile,reviewFile): | ||
for field in app[1].keys(): | ||
app[0][field] = app[1][field] | ||
results +=[app[0]] | ||
|
||
with open(directory + "/" + allJson[:-8]+"merged.json",'w') as f: | ||
json.dump(results,f,sort_keys=True) | ||
|
||
print "Results written to",directory+"/"+allJson[:-8]+"merged.json" | ||
return | ||
|
||
|
||
|