Last active
December 31, 2015 05:09
-
-
Save neumino/7938782 to your computer and use it in GitHub Desktop.
emmo - IRC - 2013.12.12
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
conn = r.connect() | |
cursor = r.db('gbrl').table('race').get_all(14136, index='season_id') \ | |
.pluck({'results':['driver', 'position']}, 'time') \ | |
.order_by('time') \ | |
.map( lambda race: | |
r.branch( # That's just a if | |
# Check if Andrew is in the results | |
race["results"]["driver"].contains("Andrew Vennaro"), | |
race["results"].filter(lambda doc: | |
doc['driver'] == 'Andrew Vennaro' | |
)[0]["position"], # The position of Andrew | |
None # We didn't find Andrew in the results | |
) | |
).run(conn) | |
for i in cursor: | |
print i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment