Beispiel #1
0
    def get(self):
        db.delete(DeviceVersions.all().fetch(400))

        total = (Device.all().count() / 10) + 1
        for x in xrange(total):
            offset = x * 10
            taskqueue.add(url='/tasks/AggregateVersionsWorker', params={'offset': offset})
Beispiel #2
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if device.version:
                DeviceVersions.increment(device.version)
Beispiel #3
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if device.type:
                DeviceAggregate.increment(device.type)
Beispiel #4
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if device.country_code:
                DeviceCountries.increment(device.country_code)
Beispiel #5
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().filter('version =', 'Unknown').fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if device.version_raw:
                UnknownVersions.increment(device.version_raw)
Beispiel #6
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if device.type:
                DeviceAggregate.increment(device.type)
Beispiel #7
0
    def get(self):
        db.delete(DeviceVersions.all().fetch(400))

        total = (Device.all().count() / 10) + 1
        for x in xrange(total):
            offset = x * 10
            taskqueue.add(url='/tasks/AggregateVersionsWorker',
                          params={'offset': offset})
Beispiel #8
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().filter('version =', 'Unknown').fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if device.version_raw:
                UnknownVersions.increment(device.version_raw)
Beispiel #9
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if device.country_code:
                DeviceCountries.increment(device.country_code)
Beispiel #10
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if device.version:
                DeviceVersions.increment(device.version)
Beispiel #11
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if not device.carrier:
                device.carrier = "Unknown"
            DeviceCarriers.increment(device.carrier)
Beispiel #12
0
    def post(self):
        offset = int(self.request.get('offset'))

        devices = Device.all().fetch(10, offset)
        for device in devices:
            logging.debug("Device: %s" % device.key().name())
            if not device.carrier:
                device.carrier = "Unknown"
            DeviceCarriers.increment(device.carrier)
    def post(self):
        post = simplejson.loads(self.request.body)

        phoneKey = None
        deviceKey = None
        brandKey = None
        benchmarkKey = None

        phoneID = None
        device = None
        brand = None
        totalScore = None
        testResults = []
        
        # get post data
        try:
            phoneID = post["phoneid"]
            device = post["device"]    
            brand = post["brand"]
            totalScore = int(post["total_score"])
            testResults = post["results"]
        except KeyError:
            self.error(404)
        
        if phoneID is not None and device is not None and brand is not None and totalScore is not None and testResults: 
            query = Phone.all()
            query.filter("phoneid =", phoneID)
            results = query.fetch(1)
            
            # get phone key
            if query.count(1) > 0:
                phoneKey = results[0].key() 
            else:
                phoneKey = Phone(
                    phoneid = phoneID
                ).put()

            query = Device.all()
            query.filter("name =", device)
            results = query.fetch(1)

            # get device key
            if query.count(1) > 0:
                deviceKey = results[0].key()
            else:       
                query = Brand.all()
                query.filter("brandname =", brand)
                results = query.fetch(1)
                
                # get brand key
                if query.count(1) > 0:
                     brandKey = results[0].key()
                else:
                    # add brand
                    brandKey = Brand(
                        brandname = brand
                    ).put()

                # add device
                deviceKey = Device(
                    brandkey = Key(brandKey),
                    name = device
                ).put()
                
            # new benchmark           
            if phoneKey is not None and deviceKey is not None:
                benchmarkKey = Benchmark(
                    phonekey = phoneKey,
                    devicekey = deviceKey,
                    total_score = totalScore
                ).put()

                if benchmarkKey is not None:                    
                    for result in testResults:
                        test = None
                        testKey = None
                        
                        try:
                            test = result["test"]
                        except KeyError:
                            self.error(404)


                        # get test key
                        query = Test.all()
                        query.filter("name =", test)
                        results = query.fetch(1)
                        
                        # get phone key
                        if query.count(1) > 0:
                            testKey = results[0].key() 

                        score = None
                        successful = None

                        try:                        
                            score = int(result["score"])
                            successful = bool(result["successful"])
                        except KeyError:
                            self.error(404)                          

                        if testKey is not None and score is not None and successful is not None:
                            # put test result
                            testResultKey = TestResult(
                                benchmarkkey = benchmarkKey,
                                testkey = testKey,
                                score = score,
                                successful = successful
                            ).put()
                            if not testResultKey:
                                self.error(405)
                                break;
                        else:
                            self.error(404)
                else:
                    self.error(404)
            else:
                self.error(404)
        else:
            self.error(404)