diff --git a/db-migration/migrate-measurement-collection-to-ttl.js b/db-migration/migrate-measurement-collection-to-ttl.js index b5f3ba2..4216177 100644 --- a/db-migration/migrate-measurement-collection-to-ttl.js +++ b/db-migration/migrate-measurement-collection-to-ttl.js @@ -6,11 +6,11 @@ while (cursor.hasNext()) { const oldCollection = `${station._id}`; const newCollection = `${station._id}-ttl`; - db[newCollection].createIndex({time: 1}, {expireAfterSeconds: 60 * 60 * 24 * 10}); db[oldCollection].aggregate([ {$set: {receivedAt: {$toDate: {$multiply: ["$time", 1000]}}}}, {$set: {time: {$toDate: {$multiply: ["$_id", 1000]}}}}, {$out: newCollection}] ); + db[newCollection].createIndex({time: 1}, {expireAfterSeconds: 60 * 60 * 24 * 10}); db[newCollection].renameCollection(oldCollection, true); } diff --git a/winds_mobi_provider/provider.py b/winds_mobi_provider/provider.py index baebf60..6c6e520 100644 --- a/winds_mobi_provider/provider.py +++ b/winds_mobi_provider/provider.py @@ -261,7 +261,8 @@ def __create_station( }, "status": status, "tz": tz, - "seen": arrow.utcnow().int_timestamp, + "seen": arrow.utcnow().int_timestamp, # deprecated + "lastSeenAt": arrow.utcnow().datetime, } return station @@ -405,7 +406,7 @@ def create_measure( measure["rain"] = self.__to_rain(rain) measure["time"] = arrow.get(measure["_id"]).datetime - measure["receivedAt"] = arrow.now().datetime + measure["receivedAt"] = arrow.utcnow().datetime fixes = self.mongo_db.stations_fix.find_one(for_station["_id"]) if fixes and "measures" in fixes: