Commit de2af576 authored by Landon DeCoito's avatar Landon DeCoito

refactored method names to use snake-case

parent 84563394
......@@ -4,7 +4,7 @@ from flask import Response
from flask import render_template
# app imports
from appmethods import updatebothdbs, runscheduleloop
from appmethods import update_both_dbs, run_schedule_loop
from redisactions import redisdb
# python imports
......@@ -40,13 +40,13 @@ def display_GC_data():
@app.route("/api/lastupdate")
def getlastupdate():
def get_last_update():
resp = Response(redisdb.lindex("dbupdatelog", 0).replace("\n", "</br>"))
return resp
try:
thread.start_new_thread(runscheduleloop, ())
thread.start_new_thread(run_schedule_loop, ())
print "started thread!"
except:
print "===================================================" \
......
# app imports
from parscript import load_data
from getconnectedscript import load_getconn_data
from getconnectedscript import load_gc_data
import redisactions as f
# python imports
......@@ -14,27 +14,24 @@ import schedule
# attempts to update both dbs and logs the result
def updatebothdbs():
livesuccess = f.livedbfill(json.dumps(load_data(), ensure_ascii=False))
gcsuccess = f.gcdbfill(json.dumps(load_getconn_data(), ensure_ascii=False))
def update_both_dbs():
livesuccess = f.live_db_fill(json.dumps(load_data(), ensure_ascii=False))
gcsuccess = f.gc_db_fill(json.dumps(load_gc_data(), ensure_ascii=False))
successLog = str(datetime.datetime.now()) \
+ "\n\nAttempted to update cache." \
+ "\n25Live: " + str(livesuccess) \
+ "\nGC: " + str(gcsuccess)
f.appendtoupdatelog(successLog)
f.append_to_update_log(successLog)
return successLog
def testprint():
print "Schedule action completed!"
# setting up cacheing
schedule.every().day.at("02:00").do(updatebothdbs)
# this must be done after the update_both_dbs def
schedule.every().day.at("02:00").do(update_both_dbs)
def runscheduleloop():
def run_schedule_loop():
runScheduler = True
while runScheduler:
schedule.run_pending()
......
......@@ -25,7 +25,7 @@ def splitAndConvertTime(strin):
return returnlist
def load_getconn_data():
def load_gc_data():
feedtext = requests.get(
"https://getconnected.gmu.edu/events/events.rss").text
feedtext = cleanup(feedtext)
......
......@@ -15,13 +15,14 @@ import redis
# function. and every time we find an error we want to run a dberrorfill()
# function.
# setting up redis database
redisdb = redis.from_url("redis://localhost:6379/0", db=0)
# this will update the live dictlist and the cachedate
# returns true if the dictlist is not empty, false otherwise
def gcdbfill(dictlist):
def gc_db_fill(dictlist):
success = redisdb.set("gcdict", dictlist)
log = str(datetime.datetime.now())
......@@ -33,7 +34,7 @@ def gcdbfill(dictlist):
# saves new dictlist in place of previous 25Live dictlist
# returns true if the dictlist is not empty, false otherwise
def livedbfill(dictlist):
def live_db_fill(dictlist):
success = redisdb.set("livedict", dictlist)
log = str(datetime.datetime.now())
......@@ -45,7 +46,7 @@ def livedbfill(dictlist):
# appends the log string to the head of our update long
# returns true if the head is the newest update
def appendtoupdatelog(logstring):
def append_to_update_log(logstring):
redisdb.lpush("dbupdatelog", logstring)
return redisdb.lindex("dbupdatelog", 0) == logstring
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment