Skip to content

Commit

Permalink
add again the graph count generation button
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jan 23, 2025
1 parent b921d17 commit f682b18
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
10 changes: 10 additions & 0 deletions app/controllers/admin/graphs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ class Admin::GraphsController < ApplicationController
def index
@graphs = LinkedData::Client::HTTP.get(GRAPHS_URL.dup, { raw: true }, { raw: true })
@graphs = MultiJson.load(@graphs)
@zombie_graphs = @graphs.select { |_, v| v[1] }
all_onts = LinkedData::Client::Models::Ontology.all
@empty_ontologies = all_onts.select { |ont| !@graphs.any? { |k, _| k.include?(ont.acronym) } }
end

def create
message = 'Graphs counts created successfully'
# response = LinkedData::Client::HTTP.post(GRAPHS_URL, {})
# message = response.status == 200 ? response.message : 'Error creating graphs counts'
redirect_to admin_index_path(section: 'graphs'), notice: message
end

end
4 changes: 2 additions & 2 deletions app/helpers/components_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ def properties_dropdown(id, title, tooltip, properties, is_open: false, &block)
end
end

def regular_button(id, value, variant: "secondary", state: "regular", size: "slim", href: nil, &block)
render Buttons::RegularButtonComponent.new(id:id, value: value, variant: variant, state: state, size: size, href: href) do |btn|
def regular_button(id, value, variant: "secondary", state: "regular", size: "slim", href: nil, type: 'button', &block)
render Buttons::RegularButtonComponent.new(id:id, value: value, variant: variant, state: state, type: type, size: size, href: href) do |btn|
capture(btn, &block) if block_given?
end
end
Expand Down
17 changes: 16 additions & 1 deletion app/views/admin/graphs/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@
= render_alerts_container
%div#site-admin-clear-caches.my-2
%div
%div

- unless @zombie_graphs.empty?
%div.my-1
= render Display::AlertComponent.new(id: 'graphs-admin-zombie', type: 'danger') do
There are #{@zombie_graphs.size} zombie graphs in the system. Please check the list below and take action.

- unless @empty_ontologies.empty?
%div.my-1
= render Display::AlertComponent.new(id: 'graphs-admin-empty-ontologies', type: 'danger') do
There are #{@empty_ontologies.size} ontologies with no graphs in the system: #{@empty_ontologies.map{|o| o[:acronym]}.join(", ")}


%div.d-flex.justify-content-between.w-100
%div
%p Total graphs: #{@graphs.size}
%p Total triples: #{@graphs.reduce(0){|sum, (k,v)| sum + v[0]}}
%p Total zombie graphs: #{@graphs.reduce(0){|sum, (k,v)| sum + (v[1] ? 1 : 0)}}
%div
= form_with url: '/admin/graphs/', method: 'post', data:{turbo: true, turbo_frame: '_top', turbo_confirm: 'This may take a while, are you sure you want to run this?'} do
= regular_button('graphs-generate', 'Generate Graphs count report', type: 'submit')
%div
= render TableComponent.new(id: 'graphs_table', paging: true, searching: true, sort_column: 1) do |t|
- t.header do |h|
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@

scope :graphs do
get '/', to: 'graphs#index'
post '/', to: 'graphs#create'
end

scope :logs do
Expand Down

0 comments on commit f682b18

Please sign in to comment.