diff --git a/app/commands/MigrationUpgrade.php b/app/commands/MigrationUpgrade.php index 924cd2d..81a5167 100644 --- a/app/commands/MigrationUpgrade.php +++ b/app/commands/MigrationUpgrade.php @@ -20,7 +20,7 @@ class MigrationUpgrade implements Asatru\Commands\Command { AppModel::raw('ALTER TABLE `' . AppModel::tableName() . '` ADD COLUMN IF NOT EXISTS owm_enable BOOLEAN NOT NULL DEFAULT 0'); AppModel::raw('ALTER TABLE `' . AppModel::tableName() . '` ADD COLUMN IF NOT EXISTS owm_api_key VARCHAR(512) NULL'); AppModel::raw('ALTER TABLE `' . AppModel::tableName() . '` ADD COLUMN IF NOT EXISTS owm_latitude DECIMAL(10, 8) NULL'); - AppModel::raw('ALTER TABLE `' . AppModel::tableName() . '` ADD COLUMN IF NOT EXISTS owm_longitude DECIMAL(10, 8) NULL'); + AppModel::raw('ALTER TABLE `' . AppModel::tableName() . '` ADD COLUMN IF NOT EXISTS owm_longitude DECIMAL(11, 8) NULL'); } /** diff --git a/app/controller/admin.php b/app/controller/admin.php index 829d20c..0ba0d73 100644 --- a/app/controller/admin.php +++ b/app/controller/admin.php @@ -580,6 +580,8 @@ class AdminController extends BaseController { AppModel::updateSet($set); + WeatherModule::clearCache(); + FlashMessage::setMsg('success', __('app.environment_settings_saved')); return redirect('/admin?tab=weather'); diff --git a/app/migrations/AppModel.php b/app/migrations/AppModel.php index ac8d0c6..12af8f8 100644 --- a/app/migrations/AppModel.php +++ b/app/migrations/AppModel.php @@ -52,7 +52,7 @@ class AppModel_Migration { $this->database->add('owm_enable BOOLEAN NOT NULL DEFAULT 0'); $this->database->add('owm_api_key VARCHAR(512) NULL'); $this->database->add('owm_latitude DECIMAL(10, 8) NULL'); - $this->database->add('owm_longitude DECIMAL(10, 8) NULL'); + $this->database->add('owm_longitude DECIMAL(11, 8) NULL'); $this->database->add('created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP'); $this->database->create(); } diff --git a/app/models/CacheModel.php b/app/models/CacheModel.php index 1e1d016..14ee09a 100644 --- a/app/models/CacheModel.php +++ b/app/models/CacheModel.php @@ -97,6 +97,24 @@ class CacheModel extends \Asatru\Database\Model { return null; } + + /** + * Reset cache of item + * + * @param string $ident The item identifier + * @return bool + */ + public static function reset($ident) + { + $item = CacheModel::find($ident, 'ident'); + if ($item->count() > 0) { + CacheModel::update('updated_at', date('1970-01-01 00:00:00'))->where('ident', '=', $ident)->go(); + + return true; + } + + return false; + } /** * Forget CacheModel item diff --git a/app/modules/WeatherModule.php b/app/modules/WeatherModule.php index d66cfb1..493f4de 100644 --- a/app/modules/WeatherModule.php +++ b/app/modules/WeatherModule.php @@ -36,6 +36,19 @@ class WeatherModule { } } + /** + * @return mixed + * @throws \Exception + */ + public static function clearCache() + { + try { + CacheModel::reset('weather_today'); + } catch (\Exception $e) { + throw $e; + } + } + /** * @param $resource * @return mixed