From de959bb5275c455dd3dba79994439b370a0f1772 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 31 Oct 2011 19:57:44 +0400 Subject: [PATCH] [refs #2161] Add refresh option to statistics --- app/controllers/downloads_controller.rb | 7 +++++++ app/views/downloads/index.html.haml | 1 + config/locales/ru.yml | 5 +++++ config/routes.rb | 1 + 4 files changed, 14 insertions(+) diff --git a/app/controllers/downloads_controller.rb b/app/controllers/downloads_controller.rb index 4be66a5db..f820cf310 100644 --- a/app/controllers/downloads_controller.rb +++ b/app/controllers/downloads_controller.rb @@ -5,4 +5,11 @@ class DownloadsController < ApplicationController def index @downloads = Download.paginate :page => params[:page], :per_page => 30 end + + def refresh + Download.rotate_nginx_log + Download.send_later :parse_and_remove_nginx_log + + redirect_to downloads_path, :notice => t('flash.downloads.statistics_refreshed') + end end diff --git a/app/views/downloads/index.html.haml b/app/views/downloads/index.html.haml index 115b114b2..1602e498d 100644 --- a/app/views/downloads/index.html.haml +++ b/app/views/downloads/index.html.haml @@ -2,6 +2,7 @@ .content %h2.title = t("layout.downloads.title") + %h3= t("layout.downloads.message") .inner %table.table %tr diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 39c97ffdc..31ab65407 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -32,6 +32,8 @@ ru: downloads: title: Статистика закачек пакетов + message: Обновляется автоматически каждые 24 часа + refresh_btn: Обновить auto_build_lists: header: Проекты с автоматической сборкой @@ -289,6 +291,9 @@ ru: project_version_not_found: версия не найден flash: + downloads: + statistics_refreshed: Статистика обновлена + collaborators: successfuly_changed: Список коллабораторов успешно изменен error_in_changing: Ошибка изменения списка коллабораторов diff --git a/config/routes.rb b/config/routes.rb index ce6dfd29e..f96dc3ac3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,7 @@ Rosa::Application.routes.draw do #resources :downloads, :only => :index match 'statistics/' => 'downloads#index', :as => :downloads + match 'statistics/refresh' => 'downloads#refresh', :as => :downloads_refresh resources :categories do get :platforms, :on => :collection