Skip to content

Commit

Permalink
Merge pull request #1943 from datadryad/stats
Browse files Browse the repository at this point in the history
Stats calculation bug fixes
  • Loading branch information
ahamelers authored Dec 5, 2024
2 parents 5b2ea87 + 1d488f6 commit 3c75742
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions app/controllers/stash_engine/curation_stats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class CurationStatsController < ApplicationController

def index
params.permit(:format)

@all_stats = authorize CurationStats.all
@current_stats = authorize CurationStats.where(date: 1.month.ago..Time.now.utc.to_date).order('date DESC')

@admin_stats = authorize StashEngine::AdminDatasetsController::Stats.new, policy_class: CurationStatsPolicy
Expand All @@ -30,7 +28,7 @@ def csv_enumerator
Enumerator.new do |rows|
rows << ['Date', 'Queue size', 'Unclaimed', 'Created', 'New to queue', 'New to PPR', 'PPR to Queue',
'Curation to AAR', 'Curation to published', 'Withdrawn', 'Author revised', 'Author versioned'].to_csv(row_sep: "\r\n")
@all_stats.order(:date).find_each do |stat|
CurationStats.order(:date).find_each do |stat|
row = [
stat.date,
stat.datasets_to_be_curated,
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/stash_engine_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ namespace :curation_stats do
desc 'Calculate any curation stats that are missing from v2 launch day until yesterday'
task recalculate_all: :environment do
launch_day = Date.new(2019, 9, 17)
(launch_day..Time.now.utc.to_date - 1.day).find_each do |date|
(launch_day..Time.now.utc.to_date - 1.day).each do |date|
print '.'
stats = StashEngine::CurationStats.find_or_create_by(date: date)
stats.recalculate unless stats.created_at > 2.seconds.ago
Expand Down

0 comments on commit 3c75742

Please sign in to comment.