def get_Alluser_work_end_time_pie(start,end):
    Worktimes=edb.get_worktime_db()
    timeCountMap = {}
    for timesection in time_list:

        key=str(timesection[0]).zfill(2) +':01 - '+str(timesection[1]).zfill(2) +':00'
        timeCountMap[key] =Worktimes.find({'dep_hour':{"$gte": timesection[0], "$lt": timesection[1]}},\
                                          {"date": {"$gte": start, "$lt": end}}).count()

    return timeCountMap
def get_user_work_start_time_pie(user,start,end):
    Worktimes=edb.get_worktime_db()
    timeCountMap = {}
    for timesection in time_list:

        key=str(timesection[0]).zfill(2) +':01 - '+str(timesection[1]).zfill(2) +':00'
        timeCountMap[key] =Worktimes.find({"$and":[{'user_id':user},{'arr_hour':{"$gte": timesection[0], "$lt": timesection[1]}},\
                                                   {"date": {"$gte": start, "$lt": end}}]}).count()

    return timeCountMap
Example #3
0
def get_user_work_start_time_pie(user, start, end):
    Worktimes = edb.get_worktime_db()
    timeCountMap = {}
    for timesection in time_list:

        key = str(timesection[0]).zfill(2) + ':01 - ' + str(
            timesection[1]).zfill(2) + ':00'
        timeCountMap[key] =Worktimes.find({"$and":[{'user_id':user},{'arr_hour':{"$gte": timesection[0], "$lt": timesection[1]}},\
                                                   {"date": {"$gte": start, "$lt": end}}]}).count()

    return timeCountMap
Example #4
0
def get_Alluser_work_end_time_pie(start, end):
    Worktimes = edb.get_worktime_db()
    timeCountMap = {}
    for timesection in time_list:

        key = str(timesection[0]).zfill(2) + ':01 - ' + str(
            timesection[1]).zfill(2) + ':00'
        timeCountMap[key] =Worktimes.find({'dep_hour':{"$gte": timesection[0], "$lt": timesection[1]}},\
                                          {"date": {"$gte": start, "$lt": end}}).count()

    return timeCountMap
Example #5
0
def get_evening_commute_distance(user, start, end):
    # day should be from 1 to 5
    # get a list of work starttime for Mon, or ...
    Sections = get_section_db()
    Worktimes = get_worktime_db()
    totalDist = 0
    projection = {'distance': True, '_id': False}
    for section in Sections.find(
        {
            "$and": [{
                'user_id': user
            }, {
                'commute': 'from'
            }, {
                "section_start_datetime": {
                    "$gte": start,
                    "$lt": end
                }
            }]
        }, projection):
        #     logging.debug("found section with %s %s %s %s %s" %
        #       (section['trip_id'], section['section_id'], section['confirmed_mode'],
        #           section['user_id'], section['type']))
        if section['distance'] != None:
            totalDist = totalDist + section['distance']
        else:
            logging.warning(
                "distance key not found in projection, returning zero...")
            # returning zero for the distance
            pass

# logging.debug("for sectionList %s, distanceList = %s" % (len(sectionList), distanceList))
    num_commute = Worktimes.find({
        "$and": [{
            'user_id': user
        }, {
            'dep_hour': {
                "$exists": True
            }
        }, {
            "date": {
                "$gte": start,
                "$lt": end
            }
        }]
    }).count()
    if num_commute == 0:
        return 'N/A'
    else:
        return totalDist / num_commute
Example #6
0
def get_evening_commute_distance(user,start,end):
    # day should be from 1 to 5
    # get a list of work starttime for Mon, or ...
    Sections=get_section_db()
    Worktimes=get_worktime_db()
    totalDist = 0
    projection = {'distance': True, '_id': False}
    for section in Sections.find({"$and":[{'user_id':user},{'commute':'from'},{"section_start_datetime": {"$gte": start, "$lt": end}}]}, projection):
#     logging.debug("found section with %s %s %s %s %s" %
#       (section['trip_id'], section['section_id'], section['confirmed_mode'],
#           section['user_id'], section['type']))
        if section['distance']!=None:
            totalDist = totalDist + section['distance']
        else:
            logging.warning("distance key not found in projection, returning zero...")
      # returning zero for the distance
            pass
  # logging.debug("for sectionList %s, distanceList = %s" % (len(sectionList), distanceList))
    num_commute=Worktimes.find({"$and":[{'user_id':user},{'dep_hour':{ "$exists": True}},{"date": {"$gte": start, "$lt": end}}]}).count()
    if num_commute==0:
        return 'N/A'
    else:
        return totalDist/num_commute