Merge lp:~vthompson/ubuntu-weather-app/reboot-migrate-to-kph-nicely into lp:ubuntu-weather-app

Proposed by Victor Thompson
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 39
Merged at revision: 42
Proposed branch: lp:~vthompson/ubuntu-weather-app/reboot-migrate-to-kph-nicely
Merge into: lp:ubuntu-weather-app
Diff against target: 41 lines (+24/-5)
1 file modified
app/data/Storage.qml (+24/-5)
To merge this branch: bzr merge lp:~vthompson/ubuntu-weather-app/reboot-migrate-to-kph-nicely
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Andrew Hayzen Approve
Review via email: mp+258699@code.launchpad.net

Commit message

* Fix migration of kmh to kph
* Add migration fixes for when the settings have not been added/changed

Description of the change

* Fix migration of kmh to kph
* Add migration fixes for when the settings have not been added/changed

This fixes the migration of using "kmh" to using "kph" and also adds fixes for migrating settings data that hadn't been changed from the defaults. When a setting is not changed it is not in the db.

To post a comment you must log in.
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

LGTM, tested the case of an empty db, metric units before and imperial units before. All settings were correctly translated :-)

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/data/Storage.qml'
2--- app/data/Storage.qml 2015-03-03 18:37:59 +0000
3+++ app/data/Storage.qml 2015-05-09 00:47:30 +0000
4@@ -70,13 +70,32 @@
5
6 console.debug("Migrating old data:", JSON.stringify(oldSettings))
7
8+ var metric = Qt.locale().measurementSystem === Locale.MetricSystem
9+
10 // Move to new Settings API
11 settings.migrated = true
12- settings.precipUnits = oldSettings["precip_units"]
13- settings.service = oldSettings["service"]
14- settings.tempScale = "°" + (oldSettings["units"] === "metric" ? "C" : "F")
15- settings.units = oldSettings["units"]
16- settings.windUnits = oldSettings["wind_units"]
17+ settings.service = oldSettings["service"] === undefined ? "weatherchannel" : oldSettings["service"]
18+
19+ if (oldSettings["precip_units"] !== undefined) {
20+ settings.precipUnits = oldSettings["precip_units"]
21+ } else {
22+ settings.precipUnits = metric ? "mm" : "in"
23+ }
24+
25+ if (oldSettings["units"] !== undefined) {
26+ settings.tempScale = oldSettings["units"] === "metric" ? "°C" : "°F"
27+ settings.units = oldSettings["units"]
28+ } else {
29+ settings.tempScale = metric ? "°C" : "°F"
30+ settings.units = metric ? "metric" : "imperial"
31+ }
32+
33+ if (oldSettings["units"] !== undefined) {
34+ // If old wind speed was in "kmh" use "kph" instead
35+ settings.windUnits = oldSettings["wind_units"] === "kmh" ? "kph" : oldSettings["wind_units"]
36+ } else {
37+ settings.windUnits = metric ? "kph" : "mph"
38+ }
39
40 /*
41 TODO: uncomment when reboot is ready to replace existing app

Subscribers

People subscribed via source and target branches

to all changes: