Last active
August 29, 2015 14:08
-
-
Save deontologician/cd1021991da2908df89c to your computer and use it in GitHub Desktop.
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
def history_query(table): | |
return table.filter( | |
lambda this_user: this_user.has_fields({'meta': {'title': True}}) | |
).filter( | |
lambda this_user: this_user.has_fields({'meta': {'updated_at': True}}) | |
).filter( | |
r.row['meta']['updated_at'].during(r.now() - int(past), r.now() + 3600) | |
).order_by( | |
r.desc(r.row['meta']['updated_at']) | |
).coerce_to('array') | |
def find_history(self, past=600): | |
db = rdb[cdb].split(':') | |
selection = history_query(r.db(db[0]).table(db[1])).run(g.rdb_conn) | |
if selection is not None: | |
#print(selection) | |
single = False | |
if len(selection) <= 15: | |
print("Length is: ", len(selection), " so expanding items.") | |
single = True | |
return render_template('pages/pagelist.html', results=selection, single=single) | |
else: | |
return "Not Found", 404 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment