diff --git a/model/daily_sensor/daily_sensor.go b/model/daily_sensor/daily_sensor.go index afc3b21..8a32b4a 100644 --- a/model/daily_sensor/daily_sensor.go +++ b/model/daily_sensor/daily_sensor.go @@ -60,6 +60,7 @@ func (s *Data) StoreData() error { return nil } +//function to update the daily temperature max or min for a location func (s *Data) UpdateData() error { if db.Mongo.Connected() { @@ -85,6 +86,8 @@ func (s *Data) UpdateData() error { } +//get the current daily sensor reading to compare +//if the max or min temp needs to be updated func GetDailySensorInfo(sensor_location string) (Data, error) { d := Data{} @@ -143,6 +146,8 @@ func GetAllSensorInfo(sensor_location string) ([]Data, error) { } } +//return all daily temperature readings per year for a location +//sort by most recent year and oldest month func GetAllSensorInfoByYear(sensor_location string, year int) ([]Data, error) { d := []Data{} @@ -168,6 +173,7 @@ func GetAllSensorInfoByYear(sensor_location string, year int) ([]Data, error) { } } +//return all temperature readings for a specific month and location func GetAllSensorInfoByMonth(sensor_location string, year int, monthname string) ([]Data, error) { d := []Data{} diff --git a/public/js/SensorInfoController.js b/public/js/SensorInfoController.js index 112dc53..2d732c7 100644 --- a/public/js/SensorInfoController.js +++ b/public/js/SensorInfoController.js @@ -10,7 +10,7 @@ app.controller('SensorInfoController', function($scope, $http, $routeParams) { if ($scope.list.length > 0) { $scope.selectedObject = $scope.list[0]; - $scope.selectedMonth = $scope.list[0].months[0]; + $scope.selectedMonth = $scope.list[0].months[$scope.list.months.length]; $scope.loadingMonth = true; $scope.loadingYear = true;