Ejemplo n.º 1
0
    def get(self):
        #One week 1458432000 - 1459036800

        #starts in 2/2/2015: 1:40:00 GMT
        #1454377200 or 2/2/2015: 1:39:59 GMT - 1454377199
        count = 0
        start = int(1454377200)
        lastPost = Regionpostsall.objects(classified = True).order_by('-event_id').limit(1)

        createdTime = int(lastPost[0].event_id)

        print createdTime

        if (createdTime > start):
            start = createdTime

        finish = start + 600 # 10min interval
        print finish

        list = Regionpostsall.objects(created_time__gt=str(start), created_time__lte=str(finish), classified = False).order_by("region.code").limit(1)

        while len(list) == 0:
            start = finish
            finish = start + 600
            list = Regionpostsall.objects(created_time__gt=str(start), created_time__lte=str(finish), classified = False).order_by("region.code").limit(1)

        region = list[0].region['code']

        print region

        while count == 0:
            print region
            posts = Regionpostsall.objects(created_time__gt=str(start), created_time__lte=str(finish), region__code = region, classified = False)
            count = len(posts)
            if count == 0:
                region = region + 1
                if (region > 624):
                    region = 0
                    start = finish
                    finish = start + 600

        '''
        print ('GET -------------------')
        print ("Number of records: " + str(len(posts)))
        print ("Start: " + str(start))
        print ("Finish: " + str(finish))
        print ("Region: " + str(region))
        '''
        return render_template('posts/postList.html', posts=posts, count= count, start = start, finish=finish, epoch=start, region = region)
Ejemplo n.º 2
0
    def post(self):
        #print ('POST -------------------')
        res = str(request.form['res'])
        #print("Answer " + res)
        event_id = int(request.form['event_id'])
        #print("EventID: " + str(event_id))
        start = int(request.form['start'])
        #print ("Start: " + str(start))
        finish = int(request.form['finish'])
        #print ("Finish: " + str(finish))
        region_code = int(request.form['region'])
        #print ("Region: " + str(region_code))
        
        posts = Regionpostsall.objects(created_time__gt=str(start), created_time__lte=str(finish), region__code = region_code, classified = False).order_by("region.code")
        #print (len(posts))
        for p in posts:
            if (res == "NO"):
              hasEvent = False
            else:
              hasEvent = True

            p.classified = True
            p.event_id = event_id
            p.hasEvent = hasEvent
            p.save(validate=False)
        
        return redirect("/")