[gnome-maps] placeStore: Add isStale method
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] placeStore: Add isStale method
- Date: Wed, 7 Jan 2015 11:23:33 +0000 (UTC)
commit 74ec97b8d907c5d4d04448276ebdebb837e174e1
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Mon Jan 5 07:36:37 2015 -0500
placeStore: Add isStale method
https://bugzilla.gnome.org/show_bug.cgi?id=742374
src/placeStore.js | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/placeStore.js b/src/placeStore.js
index 69c12b9..da504dd 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -31,6 +31,8 @@ const Utils = imports.utils;
const _PLACES_STORE_FILE = 'maps-places.json';
const _ICON_SIZE = 20;
+const _ONE_DAY = 1000 * 60 * 60 * 24; // one day in ms
+const _STALE_THRESHOLD = 7; // mark the osm information as stale after a week
const PlaceType = {
ANY: -1,
@@ -223,6 +225,26 @@ const PlaceStore = new Lang.Class({
return storedPlace;
},
+ isStale: function(place) {
+ if (!this.exists(place, null))
+ return false;
+
+ let added = null;
+ this.foreach(function(model, path, iter) {
+ let p = model.get_value(iter, Columns.PLACE);
+
+ if (p.uniqueID === place.uniqueID) {
+ let p_type = model.get_value(iter, Columns.TYPE);
+ added = model.get_value(iter, Columns.ADDED);
+ }
+ });
+
+ let now = new Date().getTime();
+ let days = Math.abs(now - added) / _ONE_DAY;
+
+ return (days >= _STALE_THRESHOLD);
+ },
+
exists: function(place, type) {
if (type !== undefined && type !== null)
return this._typeTable[place.uniqueID] === type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]