if timestamp is not None:
extra_cond = 'extract(epoch from bin_associations.created) > %d' % timestamp
query = query.filter(extra_cond)
if timestamp is not None:
extra_cond = 'extract(epoch from bin_associations.created) > %d' % timestamp
query = query.filter(extra_cond)