Merge lp:~martin-borho/ubuntu-weather-app/reboot-data-fixes into lp:ubuntu-weather-app

Proposed by Martin Borho
Status: Merged
Approved by: Martin Borho
Approved revision: 24
Merged at revision: 18
Proposed branch: lp:~martin-borho/ubuntu-weather-app/reboot-data-fixes
Merge into: lp:ubuntu-weather-app
Diff against target: 108 lines (+12/-11)
4 files modified
app/data/WeatherApi.js (+5/-4)
app/ubuntu-weather-app.qml (+3/-3)
app/ui/settings/RefreshIntervalPage.qml (+1/-1)
app/ui/settings/UnitsPage.qml (+3/-3)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/reboot-data-fixes
Reviewer Review Type Date Requested Status
Victor Thompson Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+252207@code.launchpad.net

Commit message

Some fixes related to data backend and data format:

* added missing settings.interval value to request parameters in data client
* respect caching after adding a new location
* updated refresh interval choices to maintain netiquette (OWM/TWC): 5 min too small, should be 10min at least (TWC)
* alignment of data format for TWC/OWM for condition-phrase, updated RESPONSE_DATA_VERSION to force a refresh at start
* do refresh only from storage after a unit-setting change

Description of the change

Some fixes related to data backend and data format:

* added missing settings.interval value to request parameters in data client
* respect caching after adding a new location
* updated refresh interval choices to maintain netiquette (OWM/TWC), 5 min too small, should be 10min at least(TWC)
* alignment of data format for TWC/OWM for condition-phrase, updated RESPONSE_DATA_VERSION to force a refresh at start
* do refresh only from storage after a unit-setting change

To post a comment you must log in.
20. By Martin Borho

updated refresh interval choices to maintain netiquette (OWM/TWC)

21. By Martin Borho

alignment of data format for TWC/OWM for condition-phrase, updated RESPONSE_DATA_VERSION to force a refresh at start

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

I have 2 inline comments:

1. There seems to be excessive spacing at the end of this line. Could you truncate it? There was no actual code change here.
2. Won't this cause the from_storage and force_refresh bools to be undefined when the function is called?

review: Needs Fixing
22. By Martin Borho

removed whitespace

23. By Martin Borho

set defaults for refreshData params

24. By Martin Borho

do refresh only from storage after a unit-setting change

Revision history for this message
Martin Borho (martin-borho) wrote :

The two issues are fixed.

Additionally, the locations are going to be refreshed only from storage after a unit-setting change. The data needed is already present.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

lgtm!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/data/WeatherApi.js'
2--- app/data/WeatherApi.js 2015-02-11 04:29:28 +0000
3+++ app/data/WeatherApi.js 2015-03-08 16:25:37 +0000
4@@ -23,7 +23,7 @@
5 * Version of the response data format.
6 * Increase this number to force a refresh.
7 */
8-var RESPONSE_DATA_VERSION = 20140315;
9+var RESPONSE_DATA_VERSION = 20150307;
10
11 /**
12 * Helper functions
13@@ -233,7 +233,7 @@
14 windDeg: data.wind.deg,
15 windDir: calcWindDir(data.wind.deg),
16 icon: _icon_map[data.weather[0].icon],
17- condition: data.weather[0]
18+ condition: data.weather[0].main
19 };
20 if(data.id !== undefined) {
21 result["service"] = _serviceName;
22@@ -263,7 +263,7 @@
23 pressure: data.pressure,
24 humidity: data.humidity,
25 icon: _icon_map[data.weather[0].icon],
26- condition: data.weather[0],
27+ condition: data.weather[0].main,
28 windDeg: data.deg,
29 windDir: calcWindDir(data.deg),
30 hourly: []
31@@ -725,7 +725,8 @@
32 db: loc.db,
33 units: 'metric',
34 service: message.params.service,
35- api_key: message.params.api_key
36+ api_key: message.params.api_key,
37+ interval: message.params.interval
38 },
39 secsFromLastFetch = (now-loc.updated)/1000;
40 if( message.params.force===true || loc.format !== RESPONSE_DATA_VERSION || secsFromLastFetch > params.interval){
41
42=== modified file 'app/ubuntu-weather-app.qml'
43--- app/ubuntu-weather-app.qml 2015-03-03 18:46:47 +0000
44+++ app/ubuntu-weather-app.qml 2015-03-08 16:25:37 +0000
45@@ -92,6 +92,8 @@
46 API instead.
47 */
48 function refreshData(from_storage, force_refresh) {
49+ from_storage = from_storage || false
50+ force_refresh = force_refresh || false
51 if(from_storage === true && force_refresh !== true) {
52 storage.getLocations(fillPages);
53 } else {
54@@ -153,9 +155,7 @@
55 if(location.dbId === undefined || location.dbId=== 0) {
56 storage.insertLocation({location: location});
57 }
58-
59- refreshData(true, false) // load new location into models (without data)
60- refreshData(false, true) // FIXME: can be really slow as it refreshes all models
61+ refreshData();
62 }
63
64 return !exists;
65
66=== modified file 'app/ui/settings/RefreshIntervalPage.qml'
67--- app/ui/settings/RefreshIntervalPage.qml 2015-02-10 14:17:08 +0000
68+++ app/ui/settings/RefreshIntervalPage.qml 2015-03-08 16:25:37 +0000
69@@ -42,7 +42,7 @@
70 text: Math.floor(modelData / 60).toString() + " " + i18n.tr("minutes")
71 }
72 expanded: true
73- model: [300, 600, 900, 1800]
74+ model: [600, 900, 1800, 3600]
75 selectedIndex: model.indexOf(settings.refreshInterval)
76 text: i18n.tr("Interval")
77
78
79=== modified file 'app/ui/settings/UnitsPage.qml'
80--- app/ui/settings/UnitsPage.qml 2015-02-10 14:17:08 +0000
81+++ app/ui/settings/UnitsPage.qml 2015-03-08 16:25:37 +0000
82@@ -45,7 +45,7 @@
83
84 onDelegateClicked: {
85 settings.tempScale = model[index]
86- refreshData()
87+ refreshData(true)
88 }
89 }
90
91@@ -57,7 +57,7 @@
92
93 onDelegateClicked: {
94 settings.precipUnits = model[index]
95- refreshData()
96+ refreshData(true)
97 }
98 }
99
100@@ -69,7 +69,7 @@
101
102 onDelegateClicked: {
103 settings.windUnits = model[index]
104- refreshData()
105+ refreshData(true)
106 }
107 }
108 }

Subscribers

People subscribed via source and target branches

to all changes: