Created
July 31, 2014 14:12
-
-
Save ThatPerson/d3073a2da40041802c9f to your computer and use it in GitHub Desktop.
The stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### APP INSTALL FUNCTIONS | |
def install(uid, aid) | |
app_deets = "select pub, id, version from apps where aid = ".aid | |
li = "insert ignore into app_vers (uid_, aid, app_vers) values (".uid.", ".aid.", ".app_deets[:version].")" | |
return app_deets[pub] | |
def update(uid, aid) | |
app_deets = "select pub, id, version from apps where aid = ".aid | |
li = "update app_vers set version = ".app_deets[:version]." where aid = ".aid." and uid_ = ".uid."" | |
return app_deets[pub] | |
def get_app_info(aid) | |
return query("select * from apps where id = ".aid) | |
# accessed by [:title] and shizzle like that | |
###### other stuff | |
def check_installed(uid, aid) | |
p = "select apps.ver, app_ver.version from app_vers, apps from apps, app_vers where app_vers.uid_ = '".uid."' and app_vers.aid = '".aid."'" | |
lo = mysqlquery(p) | |
if lo.num_rows == 0 | |
return -1 # not installed | |
else | |
if lo.ver == lo.version | |
return 1 # installed and up to date | |
else | |
return 0 # installed and not up to date | |
def get_apps(max, min) | |
l = "select * from apps where id > ".min." and id < ".max | |
lik = query(l) # should be array so I can do lik[1]["name"] | |
for i in get_apps((page-1)*20,page*20) | |
l = check_installed(uid, i["id"]) | |
print l["name"] | |
if l == -1 | |
print red button | |
elif l == 0 | |
print amber button | |
elif l == 1 | |
print green button | |
# when you click on the title it goes to an app info page. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment