Skip to content

Instantly share code, notes, and snippets.

@mmeisinger
Last active August 29, 2015 14:00
Show Gist options
  • Save mmeisinger/fc73be7c5f46f979e92a to your computer and use it in GitHub Desktop.
Save mmeisinger/fc73be7c5f46f979e92a to your computer and use it in GitHub Desktop.
def get_user_events(nr_list, start_time):
dq = DatastoreQueryBuilder(datastore=DataStore.DS_EVENTS, profile=DataStore.DS_PROFILE.EVENTS)
where_list = []
for nr in user_nr_list:
nr_condition_and = []
if nr.origin:
nr_condition_and.append(qb.eq(qb.EA_ORIGIN, nr.origin)
if nr.origin_type:
nr_condition_and.append(qb.eq(qb.EA_ORIGIN_TYPE, nr.origin_type)
if nr.event_type:
nr_condition_and.append(qb.eq(qb.EA_EVENT_TYPE, nr.event_type)
if nr_condition_and:
where_list.append(qb.and_(*nr_condition_and))
where = qb.and_(dq.gte(DQ.RA_TS_CREATED, start_time), qb.or_(*where_list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment