Skip to content

Commit

Permalink
added new folders
Browse files Browse the repository at this point in the history
  • Loading branch information
lunaceee committed Jun 19, 2017
1 parent a5bea10 commit 516e029
Show file tree
Hide file tree
Showing 236 changed files with 3,572 additions and 0 deletions.
18 changes: 18 additions & 0 deletions back_end/cron_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# delete from cache
# where created_at < now() - interval '3 days';
import os
import datetime
import sqlalchemy
from sqlalchemy.schema import Table
from sqlalchemy.schema import MetaData

print 'Running cron job'


too_old = datetime.datetime.today() - datetime.timedelta(days=3)
db_url = os.environ.get('DATABASE_URL', 'postgresql:///wesworld')
engine = sqlalchemy.create_engine(db_url)
meta = MetaData()
meta.reflect(bind=engine)
cache_table = meta.tables['cache']
engine.execute(cache_table.delete().where(cache_table.c.created_at <= too_old))
Loading

0 comments on commit 516e029

Please sign in to comment.