← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

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

 

Victor Thompson has proposed merging lp:~vthompson/ubuntu-weather-app/reboot-migrate-to-kph-nicely into lp:ubuntu-weather-app/reboot.

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

Requested reviews:
  Ubuntu Weather Developers (ubuntu-weather-dev)

For more details, see:
https://code.launchpad.net/~vthompson/ubuntu-weather-app/reboot-migrate-to-kph-nicely/+merge/258699

* 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.
-- 
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~vthompson/ubuntu-weather-app/reboot-migrate-to-kph-nicely into lp:ubuntu-weather-app/reboot.
=== modified file 'app/data/Storage.qml'
--- app/data/Storage.qml	2015-03-03 18:37:59 +0000
+++ app/data/Storage.qml	2015-05-09 00:46:01 +0000
@@ -70,13 +70,32 @@
 
                 console.debug("Migrating old data:", JSON.stringify(oldSettings))
 
+                var metric = Qt.locale().measurementSystem === Locale.MetricSystem
+
                 // Move to new Settings API
                 settings.migrated = true
-                settings.precipUnits = oldSettings["precip_units"]
-                settings.service = oldSettings["service"]
-                settings.tempScale = "°" + (oldSettings["units"] === "metric" ? "C" : "F")
-                settings.units = oldSettings["units"]
-                settings.windUnits = oldSettings["wind_units"]
+                settings.service = oldSettings["service"] === undefined ? "weatherchannel" : oldSettings["service"]
+
+                if (oldSettings["precip_units"] !== undefined) {
+                    settings.precipUnits = oldSettings["precip_units"]
+                } else {
+                     settings.precipUnits = metric ? "mm" : "in"
+                }
+
+                if (oldSettings["units"] !== undefined) {
+                    settings.tempScale = oldSettings["units"] === "metric" ? "°C" : "°F"
+                    settings.units = oldSettings["units"]
+                } else {
+                    settings.tempScale = metric ? "°C" : "°F"
+                    settings.units = metric ? "metric" : "imperial"
+                }
+
+                if (oldSettings["units"] !== undefined) {
+                    // If old wind speed was in "kmh" use "kph" instead
+                    settings.windUnits = oldSettings["wind_units"] === "kmh" ? "kph" : oldSettings["wind_units"]
+                } else {
+                    settings.windUnits = metric ? "kph" : "mph"
+                }
 
                 /*
                   TODO: uncomment when reboot is ready to replace existing app


Follow ups