Пример #1
0
 def all_newest(cls):
     ids = [s.sensor_id for s in Sensor.all()]
     ret = []
     for i in ids:
         s = SensorData.query(SensorData.sensor_id == i).order(-SensorData.added).fetch(1)
         if s:
             ret.append(s[0])
     return ret
Пример #2
0
    def get(self):
        res = Sensor.all()

        # write response
        self.response.content_type = "application/json"
        self.response.write(jsonify([x.json() for x in res]))
Пример #3
0
 def all_newest_both(cls):
     ids = Sensor.all()
     return [(i, SensorData.query(SensorData.sensor_id == i.sensor_id).order(-SensorData.added).fetch(1)[0]) for i in
             ids]