Exemplo n.º 1
0
def geo_loc_json(request):
    if request.method == 'GET':
      GET = request.GET
      if GET.has_key('sDate') and GET.has_key('eDate'):
         eStats = EvernoteStatistics(request.user.profile)
         startDate = date.fromtimestamp(float(GET['sDate'])/1000)
         endDate = date.fromtimestamp(float(GET['eDate'])/1000)
         filt = eStats.create_date_filter(startDate, endDate)
         noteMetadata = eStats.get_note_metadata(filt)
         if noteMetadata is None:
            return HttpResponse({},content_type='application/json')
         jsonText = json.dumps({'points' : noteMetadata['geoLocations']})
         return HttpResponse(jsonText,content_type='application/json')
Exemplo n.º 2
0
def day_count_json(request):
    if request.method == 'GET':
      GET = request.GET
      if GET.has_key('sDate') and GET.has_key('eDate'):
         eStats = EvernoteStatistics(request.user.profile)
         startDate = date.fromtimestamp(float(GET['sDate'])/1000)
         endDate = date.fromtimestamp(float(GET['eDate'])/1000)
         filt = eStats.create_date_filter(startDate, endDate)
         noteMetadata = eStats.get_note_metadata(filt)
         if noteMetadata is None:
            return HttpResponse({},content_type='application/json')
         dayFrequency = noteMetadata['dayCounter']
         intToDayMap = {0: "Sunday", 1: "Monday", 2: "Tuesday",
                        3: "Wednesday", 4: "Thursday", 5: "Friday",
                        6: "Saturday"}
         daysArray = [[x,0] for x in intToDayMap.values()]
         for (k,v) in dayFrequency.iteritems():
            daysArray[k][1] = v
         jsonText = json.dumps({'categoryCounts': daysArray,
                                'categoryTitle': 'Day'})
         return HttpResponse(jsonText,content_type='application/json')
Exemplo n.º 3
0
def month_count_json(request):
    if request.method == 'GET':
      GET = request.GET
      if GET.has_key('sDate') and GET.has_key('eDate'):
         eStats = EvernoteStatistics(request.user.profile)
         startDate = date.fromtimestamp(float(GET['sDate'])/1000)
         endDate = date.fromtimestamp(float(GET['eDate'])/1000)
         filt = eStats.create_date_filter(startDate, endDate)
         noteMetadata = eStats.get_note_metadata(filt)
         if noteMetadata is None:
            return HttpResponse({},content_type='application/json')
         monthFrequency = noteMetadata['monthCounter']
         intToMonthMap = {1: "January", 2: "February", 3: "March",
                          4: "April", 5: "May", 6: "June",
                          7: "July", 8: "August", 9: "September",
                         10: "October", 11: "November", 12: "December"}
         monthsArray = [[x,0] for x in intToMonthMap.values()]
         for (k,v) in monthFrequency.iteritems():
            monthsArray[k-1][1] = v
         jsonText = json.dumps({'categoryCounts': monthsArray,
                                'categoryTitle': 'Month'})
         return HttpResponse(jsonText,content_type='application/json')