Skip to content

Instantly share code, notes, and snippets.

@neumino
Last active December 31, 2015 05:09
Show Gist options
  • Save neumino/7938782 to your computer and use it in GitHub Desktop.
Save neumino/7938782 to your computer and use it in GitHub Desktop.
emmo - IRC - 2013.12.12
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