diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 54b1725f9..427545716 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -2,13 +2,13 @@ class FilesController < ApplicationController include MessagesHelper before_action :require_login, :check_auth, except: %i[index] - before_action :find_course, except: %i[public_with_course_and_project mine_with_course_and_project] + before_action :find_course, except: %i[public_with_course_and_project mine_with_course_and_project update_visits] before_action :find_ids, only: %i[bulk_delete bulk_send bulk_move bulk_public bulk_publish] before_action :file_validate_sort_type, only: :index before_action :validate_send_message_to_course_params, only: :bulk_send before_action :set_pagination, only: %i[index public_with_course_and_project mine_with_course_and_project] before_action :validate_upload_params, only: %i[import] - before_action :find_file, only: %i[show setting update] + before_action :find_file, only: %i[show setting update update_visits] before_action :publish_params, only: %i[upload import update] SORT_TYPE = %w[created_on downloads quotes] @@ -355,6 +355,11 @@ class FilesController < ApplicationController end end + def update_visits + @file.increment!(:downloads) + render_ok + end + private def find_file @file = Attachment.find params[:id] diff --git a/config/routes.rb b/config/routes.rb index 7bf1b6c1b..3cda05f0d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -464,6 +464,7 @@ Rails.application.routes.draw do end member do get :histories + post :update_visits end end