← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~martin-borho/ubuntu-weather-app/reboot-fix-missing-icon-conditons-twc into lp:ubuntu-weather-app/reboot

 

Martin Borho has proposed merging lp:~martin-borho/ubuntu-weather-app/reboot-fix-missing-icon-conditons-twc into lp:ubuntu-weather-app/reboot.

Commit message:
Fix for missing condtion and icon at TWC.

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

For more details, see:
https://code.launchpad.net/~martin-borho/ubuntu-weather-app/reboot-fix-missing-icon-conditons-twc/+merge/253763

Fix for missing condtion and icon at TWC. Using the first icon or condition from the hourly forecast.

Fills also the missing icons mentioned in https://code.launchpad.net/~martin-borho/ubuntu-weather-app/reboot-flatten-locationpage/+merge/253762
-- 
Your team Ubuntu Weather Developers is requested to review the proposed merge of lp:~martin-borho/ubuntu-weather-app/reboot-fix-missing-icon-conditons-twc into lp:ubuntu-weather-app/reboot.
=== modified file 'app/data/WeatherApi.js'
--- app/data/WeatherApi.js	2015-03-16 13:42:08 +0000
+++ app/data/WeatherApi.js	2015-03-21 17:44:02 +0000
@@ -23,7 +23,7 @@
 *  Version of the response data format.
 *  Increase this number to force a refresh.
 */
-var RESPONSE_DATA_VERSION = 20150307;
+var RESPONSE_DATA_VERSION = 20150321;
 
 /**
 * Helper functions
@@ -533,18 +533,27 @@
             tmpResult[day] = _buildDayFormat(date, dayData, nowMs);
         }
         //
+        if(data["forecast"] !== undefined) {
+            data["forecast"].forEach(function(hourData) {
+                var dateData = getLocationTime((hourData.dateTime*1000)+offset),
+                    day = dateData.year+"-"+dateData.month+"-"+dateData.date;
+                if(tmpResult[day]) {
+                    tmpResult[day]["hourly"].push(_buildDataPoint(dateData, hourData));
+                }
+            })
+        }
+        //
         if(data["current"]) {
-            var today = todayDate.year+"-"+todayDate.month+"-"+todayDate.date
+            var today = todayDate.year+"-"+todayDate.month+"-"+todayDate.date;
             tmpResult[today]["current"] = _buildDataPoint(todayDate, data["current"]);
-        }
-        if(data["forecast"] !== undefined) {
-            data["forecast"].forEach(function(hourData) {
-                var dateData = getLocationTime((hourData.dateTime*1000)+offset),
-                    day = dateData.year+"-"+dateData.month+"-"+dateData.date;
-                if(tmpResult[day]) {                    
-                    tmpResult[day]["hourly"].push(_buildDataPoint(dateData, hourData));
-                }
-            })
+            // if the icon is missing, use the first from the hourly forecast
+            if(!tmpResult[today]["current"].icon && tmpResult[today]["hourly"] && tmpResult[today]["hourly"].length > 0) {
+                tmpResult[today]["current"].icon = tmpResult[today]["hourly"][0].icon;
+            }
+            // if condtion text is missing, use the conditon from the first hourly forecast
+            if(tmpResult[today]["current"].condition === "-" && tmpResult[today]["hourly"] && tmpResult[today]["hourly"].length > 0) {
+                tmpResult[today]["current"].condition = tmpResult[today]["hourly"][0].condition;
+            }
         }
         //
         for(var d in tmpResult) {


Follow ups