Skip to content

Commit

Permalink
extract graph count path in a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jan 14, 2025
1 parent d1c523f commit 05115d7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions controllers/admin_graphs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
class AdminGraphsController < ApplicationController

namespace '/admin' do
GRAPH_COUNT_REPORT_PATH = NcboCron.settings.graphs_counts_report_path
before do
if LinkedData.settings.enable_security && (!env['REMOTE_USER'] || !env['REMOTE_USER'].admin?)
error 403, 'Access denied'
end
end

get '/graphs' do
file_path = NcboCron.settings.graph_counts_report_path
output = NcboCron::GraphsCounts.new.read_graph_counts(file_path)
output = NcboCron::GraphsCounts.new(nil, GRAPH_COUNT_REPORT_PATH).read_graph_counts
reply output
end

post '/graphs' do
file_path = NcboCron.settings.graph_counts_report_path
NcboCron::GraphsCounts.new.run(Logger.new($stdout), file_path)
NcboCron::GraphsCounts.new(nil, GRAPH_COUNT_REPORT_PATH).run
reply({ message: 'Graph counts generated', status: 200 })
end

Expand Down

0 comments on commit 05115d7

Please sign in to comment.