After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 742374 - Refresh from overpass if place is stale
Refresh from overpass if place is stale
Status: RESOLVED FIXED
Product: gnome-maps
Classification: Applications
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gnome-maps-maint
gnome-maps-maint
Depends on:
Blocks:
 
 
Reported: 2015-01-05 12:40 UTC by Jonas Danielsson
Modified: 2015-01-07 11:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
placeStore: Make updatePlace public (1014 bytes, patch)
2015-01-05 12:41 UTC, Jonas Danielsson
committed Details | Review
placeStore: Add isStale method (1.66 KB, patch)
2015-01-05 12:42 UTC, Jonas Danielsson
committed Details | Review
searchResultBubble: Refresh place if stale (1.60 KB, patch)
2015-01-05 12:42 UTC, Jonas Danielsson
committed Details | Review

Description Jonas Danielsson 2015-01-05 12:40:07 UTC
So if a place has been in the placeStore for > threshhold we could refresh it from overpass.
I will attach patches that do so for a threshold of 7 days.

Even if we do this we still risk having stale information since not all our data comes from Overpass. What we really would need is for geocode-glib to get a new constructor:

geocode_reverse_new_for_osm_id

or something similar, that takes osm_id and osm_type and reverse geocodes the place for us according to: http://wiki.openstreetmap.org/wiki/Nominatim#Parameters_2
Comment 1 Jonas Danielsson 2015-01-05 12:41:57 UTC
Created attachment 293812 [details] [review]
placeStore: Make updatePlace public
Comment 2 Jonas Danielsson 2015-01-05 12:42:01 UTC
Created attachment 293813 [details] [review]
placeStore: Add isStale method
Comment 3 Jonas Danielsson 2015-01-05 12:42:05 UTC
Created attachment 293814 [details] [review]
searchResultBubble: Refresh place if stale
Comment 4 Mattias Bengtsson 2015-01-05 22:40:24 UTC
Review of attachment 293812 [details] [review]:

ACK
Comment 5 Mattias Bengtsson 2015-01-05 22:49:09 UTC
Review of attachment 293813 [details] [review]:

Some small comments.

::: src/placeStore.js
@@ +33,3 @@
 const _ICON_SIZE = 20;
+const _ONE_DAY = 1000 * 60 * 60 * 24; // one day in ms
+const _STALE_THRESHHOLD = 7; // mark the osm information as stale after a week

THRESHOLD (you got an extra H there).

@@ +242,3 @@
+        let now = new Date().getTime();
+        let days = Math.round(Math.abs(now - added) / _ONE_DAY);
+        if (days >= _STALE_THRESHHOLD)

Same here then :)

Also not sure about the math. Currently isStale tests for places older than 6.5 days (because of the Math.round() call). Maybe just skip the Math.round()-call?

@@ +245,3 @@
+            return true;
+        else
+            return false;

Style-nit:

> return (days >= _STALE_THRESHOLD);
Comment 6 Mattias Bengtsson 2015-01-05 22:56:14 UTC
Review of attachment 293814 [details] [review]:

Looks good, just a style nit.

::: src/searchResultBubble.js
@@ +67,3 @@
+                    Application.placeStore.updatePlace(this.place);
+                }).bind(this));
+            }

I think we should swap these if branches. So that it is like this:

// If the place is stale, update from Overpass
if (Application.placeStore.isStale(this.place)) {
    overpass.addInfo(this.place, (function(status, code) {
        this._populate(this.place);
        Application.placeStore.updatePlace(this.place);
    }).bind(this));
} else {
    let place = Application.placeStore.get(this.place);
    this._populate(place);
}

(this makes the comment apply to the code directly below.)
Comment 7 Mattias Bengtsson 2015-01-05 22:56:52 UTC
If you agree with the comments above, feel free to just push after fixing them. :)
Comment 8 Jonas Danielsson 2015-01-07 11:23:55 UTC
Thanks!