def g_json_by_today(): today = util.date_today() tomorrow = util.date_tomorrow() cfg.logger.debug("today: %s tomorrow: %s", today, tomorrow) start_timestamp = util.date_to_timestamp(today) end_timestamp = util.date_to_timestamp(tomorrow) return _process_result(g_json_handler(start_timestamp, end_timestamp))
def get_json_today_by_start_date_handler(start_date, params): start_timestamp = util.date_to_timestamp(start_date) next_id = params.get('next_id', '') sort_order = params.get('order', 'DESC') num_query = util._int(params.get('num_query', DEFAULT_NUM_QUERY)) is_desc = sort_order in ['DESC', 'desc'] today = util.date_today() today_timestamp = util.date_to_timestamp(today) cfg.logger.debug('start_timestamp: %s today_timestamp: %s', start_timestamp, today_timestamp) the_query = { 'start_timestamp': { '$lte': start_timestamp }, 'end_timestamp': { '$gte': today_timestamp } } if next_id: query_key = '$lte' if is_desc else '$gte' the_query['json_id'] = {query_key: next_id} db_results = util.db_find_it('roadDB', the_query, { '_id': False, 'extension': False }) sort_flag = pymongo.DESCENDING if is_desc else pymongo.ASCENDING db_results.sort([('json_id', sort_flag)]).limit(num_query) results = list(db_results) cfg.logger.debug('start_date: %s next_id: %s num_query: %s', start_date, next_id, num_query) for (idx, result) in enumerate(results): cfg.logger.debug('idx: %s result: %s', idx, result) return results
def g_json_by_date_sketch(): params = dict(request.params) start_timestamp = util.date_to_timestamp(params['begin_at']) end_timestamp = util.date_to_timestamp(params['end_at']) return _process_result(g_json_sketch_handler(start_timestamp, end_timestamp))