Skip to content

Commit

Permalink
Added incomplete pages and pages needing review to collection statist…
Browse files Browse the repository at this point in the history
…ics for #3041
  • Loading branch information
sylvieed committed Apr 5, 2022
1 parent fdc47ff commit 000a8da
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
17 changes: 10 additions & 7 deletions app/models/collection_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ def get_stats_hash(start_date=nil, end_date=nil)

stats =
{
:works => self.works.count,
:pages => self.works.joins(:pages).where(timeframe(start_date, end_date, 'pages.created_on')).count,
:subjects => self.articles.where(timeframe(start_date, end_date, 'created_on')).count,
:mentions => self.articles.joins(:page_article_links).where(timeframe(start_date, end_date, 'page_article_links.created_on')).count,
:contributors => self.deeds.where(timeframe(start_date, end_date)).select('user_id').distinct.count,
:descriptions => self.works.where(description_status: Work::DescriptionStatus::DESCRIBED).count,
:line_count => self.line_count
:works => self.works.count,
:pages => self.works.joins(:pages).where(timeframe(start_date, end_date, 'pages.created_on')).count,
:subjects => self.articles.where(timeframe(start_date, end_date, 'created_on')).count,
:mentions => self.articles.joins(:page_article_links).where(timeframe(start_date, end_date, 'page_article_links.created_on')).count,
:contributors => self.deeds.where(timeframe(start_date, end_date)).select('user_id').distinct.count,
:pages_transcribed => self.pages.where(status: Page::COMPLETED_STATUSES).where(timeframe(start_date, end_date,'pages.edit_started_at')).count,
:pages_incomplete => self.pages.where(status: Page::NEEDS_WORK_STATUSES).where(timeframe(start_date, end_date, 'pages.edit_started_at')).count,
:pages_needing_review => self.pages.where(status: Page::STATUS_NEEDS_REVIEW).where(timeframe(start_date, end_date, 'pages.edit_started_at')).count,
:descriptions => self.works.where(description_status: Work::DescriptionStatus::DESCRIBED).count,
:line_count => self.line_count
}

stats.merge(deeds)
Expand Down
10 changes: 6 additions & 4 deletions app/views/statistics/_collection_statistics.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
.counter(data-prefix="#{number_with_delimiter stats[:mentions]}") #{t('.reference').pluralize(stats[:mentions])}
.counter(data-prefix="#{number_with_delimiter stats[:contributors]}") #{t('.collaborator').pluralize(stats[:contributors])}
.collection-stats_counters
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_TRANSCRIPTION]}") #{t('.page').pluralize(stats[DeedType::PAGE_TRANSCRIPTION])} transcribed
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_EDIT]}") =t('.page_edits')
.counter(data-prefix="#{number_with_delimiter stats[:pages_transcribed]}") #{t('.page').pluralize(stats[:pages_transcribed])} #{t('.transcribed')}
.counter(data-prefix="#{number_with_delimiter stats[:pages_incomplete]}") #{t('.page').pluralize(stats[:pages_incomplete])} #{t('.incomplete')}
.counter(data-prefix="#{number_with_delimiter stats[:pages_needing_review]}") #{t('.page').pluralize(stats[:pages_needing_review])} #{t('.needing_review')}
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_EDIT]}") #{t('.page')} #{t('.edit').pluralize(stats[DeedType::PAGE_EDIT])}
-unless subjects_disabled
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_INDEXED]}") #{t('.page').pluralize(stats[DeedType::PAGE_INDEXED])} indexed
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_INDEXED]}") #{t('.page').pluralize(stats[DeedType::PAGE_INDEXED])} #{t('.indexed')}
-if @collection.works.where(supports_translation: true).exists?
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_TRANSLATED]}") #{t('.page').pluralize(stats[DeedType::PAGE_TRANSLATED])} translated
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_TRANSLATED]}") #{t('.page').pluralize(stats[DeedType::PAGE_TRANSLATED])} #{t('.translated')}
-if @collection.works.where(ocr_correction: true).exists?
.counter(data-prefix="#{number_with_delimiter stats[DeedType::OCR_CORRECTED]}") #{t('.ocr_correction').pluralize(stats[DeedType::OCR_CORRECTED])}
-if @collection.metadata_entry?
Expand Down
13 changes: 8 additions & 5 deletions app/views/statistics/_recent_statistics.html.slim
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
section.collection-stats_recent
.counter(data-prefix="#{number_with_delimiter stats[:contributors]}") #{t('.collaborator').pluralize(stats[:contributors])}
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_TRANSCRIPTION]}") #{t('.page').pluralize(stats[DeedType::PAGE_TRANSCRIPTION])} transcribed
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_EDIT]}") #{t('.page_edit').pluralize(stats[DeedType::PAGE_EDIT])}
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_TRANSCRIPTION]}") #{t('.page').pluralize(stats[DeedType::PAGE_TRANSCRIPTION])} #{t('.transcribed')}
.counter(data-prefix="#{number_with_delimiter stats[DeedType::NEEDS_REVIEW]}") #{t('.page').pluralize(stats[DeedType::NEEDS_REVIEW])} #{t('.marked_needs_review')}
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_EDIT]}") #{t('.page')} #{t('.edit').pluralize(stats[DeedType::PAGE_EDIT])}
-if @collection.works.where(supports_translation: true).exists?
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_TRANSLATED]}") #{t('.page').pluralize(stats[DeedType::PAGE_TRANSLATED])} #{t('.translated')}
-unless subjects_disabled
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_INDEXED]}") #{t('.page').pluralize(stats[DeedType::PAGE_INDEXED])} indexed
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_INDEXED]}") #{t('.page').pluralize(stats[DeedType::PAGE_INDEXED])} #{t('.indexed')}
.counter(data-prefix="#{number_with_delimiter stats[:mentions]}") #{t('.reference').pluralize(stats[:mentions])}
.counter(data-prefix="#{number_with_delimiter stats[:subjects]}") #{t('.new_subject').pluralize(stats[:subjects])}
.counter(data-prefix="#{number_with_delimiter stats[DeedType::NOTE_ADDED]}") #{t('.note').pluralize(stats[DeedType::NOTE_ADDED])}
.counter(data-prefix="#{number_with_delimiter stats[DeedType::PAGE_TRANSLATED]}") #{t('.page').pluralize(stats[DeedType::PAGE_TRANSLATED])} translated
.counter(data-prefix="#{number_with_delimiter stats[DeedType::OCR_CORRECTED]}") #{t('.ocr_correction').pluralize(stats[DeedType::OCR_CORRECTED])}
-if @collection.works.where(ocr_correction: true).exists?
.counter(data-prefix="#{number_with_delimiter stats[DeedType::OCR_CORRECTED]}") #{t('.ocr_correction').pluralize(stats[DeedType::OCR_CORRECTED])}

0 comments on commit 000a8da

Please sign in to comment.