From 97ca8aea38bdeaadf320a3e5b890cc4e64a8c88d Mon Sep 17 00:00:00 2001 From: waisaed Date: Tue, 14 Nov 2023 15:03:49 -0500 Subject: [PATCH 01/13] add labels and roles to search boxes --- app/javascript/catalog/CatalogToolbar.jsx | 8 ++++++++ app/javascript/catalog/search_results/SearchForm.jsx | 4 ++++ app/javascript/reading_list/CaseChooser.jsx | 7 +++++++ app/views/deployments/index.html.haml | 6 ++++-- app/views/layouts/admin.html.erb | 4 ++-- config/locales/en.yml | 1 + 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/javascript/catalog/CatalogToolbar.jsx b/app/javascript/catalog/CatalogToolbar.jsx index 05d0efda3..e6c8d31e2 100644 --- a/app/javascript/catalog/CatalogToolbar.jsx +++ b/app/javascript/catalog/CatalogToolbar.jsx @@ -99,12 +99,20 @@ class SearchField extends React.Component< onSubmit={this.handleSubmit} ref={ref} > + (this.input = el)} className="pt-round" leftIcon="search" + aria-label={this.props.intl.formatMessage({ + id: 'search.searchCases', + })} rightElement={ + diff --git a/config/locales/en.yml b/config/locales/en.yml index c3c28752a..43485d53e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1023,6 +1023,7 @@ en: results: Search results search: Search search_cases: Search Cases... + submit_search: Submit search try_again: Try searching for something else. spotlights: add_citation: > From d73ad88c9e687aadf68d979b8f4ee7632a213d06 Mon Sep 17 00:00:00 2001 From: waisaed Date: Fri, 1 Dec 2023 12:56:42 -0500 Subject: [PATCH 02/13] add dummy link to case stats page --- app/views/my_cases/index.html.haml | 9 ++++++++- config/locales/en.yml | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/views/my_cases/index.html.haml b/app/views/my_cases/index.html.haml index 2db66c8c6..528097fc5 100644 --- a/app/views/my_cases/index.html.haml +++ b/app/views/my_cases/index.html.haml @@ -15,7 +15,6 @@ aria: { label: I18n.t('helpers.help') }, target: '_blank', rel: 'noopener noreferrer' do -# Empty - :markdown #{t '.put_your_own_cases_on_gala'} .pt-callout.pt-icon-hand-right @@ -51,6 +50,7 @@ %td= t 'activerecord.attributes.case.locale' %td= t 'activerecord.attributes.case.library' %td= t 'activerecord.attributes.case.published' + %td= t 'my_cases.index.case_stats' %td %td %td @@ -90,6 +90,11 @@ - else — + %td + = link_to '', edit_case_settings_path(kase), + aria: { label: t('.case_stats') }, + class: 'pt-button pt-minimal pt-icon-series-search' + %td = link_to '', edit_case_path(kase), aria: { label: t('.edit_case') }, @@ -104,6 +109,8 @@ = link_to '', case_confirm_deletion_path(kase), class: 'pt-button pt-minimal pt-intent-danger pt-icon-trash', aria: { label: t('.delete_case') } + + - else .pt-non-ideal-state diff --git a/config/locales/en.yml b/config/locales/en.yml index 43485d53e..520bb604d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -830,6 +830,7 @@ en: Invite Someone to Manage this Library my_cases: index: + case_stats: Case Stats confirm_delete: > Are you sure you wish to delete this case? This action cannot be undone. create_a_case: Create a Case From 5d41b4262fc6a039838cbb2fa0589ca2c95aa7ab Mon Sep 17 00:00:00 2001 From: Alex Fichter Date: Mon, 8 Jan 2024 11:12:43 -0500 Subject: [PATCH 03/13] added route/controller/view and updated link --- app/controllers/cases/stats_controller.rb | 42 +++++++++++++++++++++++ app/views/cases/stats/show.html.haml | 26 ++++++++++++++ app/views/my_cases/index.html.haml | 2 +- config/locales/en.yml | 3 ++ config/routes.rb | 2 ++ 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 app/controllers/cases/stats_controller.rb create mode 100644 app/views/cases/stats/show.html.haml diff --git a/app/controllers/cases/stats_controller.rb b/app/controllers/cases/stats_controller.rb new file mode 100644 index 000000000..cb3ed5992 --- /dev/null +++ b/app/controllers/cases/stats_controller.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Cases + # The stats for a {Case} include its slug, what library it is in, etc. + class StatsController < ApplicationController + before_action :authenticate_reader! + + layout 'admin' + + # @param [GET] /cases/case-slug/stats + def show + set_case + set_libraries + set_editorships + set_group_and_deployment + end + + private + + def set_case + @case = Case.friendly.find(params[:case_slug]).decorate + @case.licensor current_reader + authorize @case + end + + def set_libraries + @libraries = LibraryPolicy::AdminScope.new(current_reader, Library) + .resolve + end + + def set_editorships + @editorships = @case.editorships + end + + def set_group_and_deployment + @enrollment = current_user.enrollment_for_case @case + @group = @enrollment.try(:active_group) || GlobalGroup.new + @deployment = @group.deployment_for_case @case + end + + end +end diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml new file mode 100644 index 000000000..e3b79a050 --- /dev/null +++ b/app/views/cases/stats/show.html.haml @@ -0,0 +1,26 @@ +- content_for :title do + = I18n.t('cases.stats.show.case_stats') + — + = @case.short_title + + +.window.admin + .admin-card.pt-card.pt-elevation-2 + = link_to case_path @case do + .case-cover-card-top{ style: "background-image: url(#{@case.cover_url})" } + %span.admin__table__slug= @case.short_title + + %div + %h1.admin__title= t '.case_stats' + %div + Date Created: + = @case.created_at + %div + Date Published: + = @case.published_at + %div + Number of Reads from Users with Acounts: + = @case.events.size + %div + Number of Deployments: + = @case.deployments.size \ No newline at end of file diff --git a/app/views/my_cases/index.html.haml b/app/views/my_cases/index.html.haml index 528097fc5..83b345fa8 100644 --- a/app/views/my_cases/index.html.haml +++ b/app/views/my_cases/index.html.haml @@ -91,7 +91,7 @@ — %td - = link_to '', edit_case_settings_path(kase), + = link_to '', case_stats_path(kase), aria: { label: t('.case_stats') }, class: 'pt-button pt-minimal pt-icon-series-search' diff --git a/config/locales/en.yml b/config/locales/en.yml index 520bb604d..33484eb6d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -261,6 +261,9 @@ en: locations: Site locations new: create_a_case: Create a Case + stats: + show: + case_stats: Case Stats settings: edit: change_library: Change library diff --git a/config/routes.rb b/config/routes.rb index 1b5bfd850..51a8bd3bc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,6 +113,8 @@ resource :settings, module: 'cases', only: %i[edit update] + resource :stats, module: 'cases', only: %i[show] + resources :taggings, only: %i[create destroy], param: :tag_name resources :translations, only: %i[new create show], param: :case_locale From 133f41300cbb46dbda103ff9ffdf975b1780cc86 Mon Sep 17 00:00:00 2001 From: waisaed Date: Fri, 12 Jan 2024 15:13:08 -0500 Subject: [PATCH 04/13] change date format and wording of case stats --- app/views/cases/stats/show.html.haml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml index e3b79a050..87690a09e 100644 --- a/app/views/cases/stats/show.html.haml +++ b/app/views/cases/stats/show.html.haml @@ -12,15 +12,16 @@ %div %h1.admin__title= t '.case_stats' - %div - Date Created: - = @case.created_at - %div - Date Published: - = @case.published_at - %div - Number of Reads from Users with Acounts: - = @case.events.size - %div - Number of Deployments: - = @case.deployments.size \ No newline at end of file + %ul + %li + Created: + = @case.created_at.strftime("%B %d, %Y") + %li + Published: + = @case.published_at.strftime("%B %d, %Y") + %li + Total Reads (signed-in users): + = @case.events.size + %li + Total Deployments: + = @case.deployments.size \ No newline at end of file From 6826c09b6b1c203702112722486474f8c4c8f5f0 Mon Sep 17 00:00:00 2001 From: waisaed Date: Wed, 17 Jan 2024 15:01:21 -0500 Subject: [PATCH 05/13] format stats list and add info callout --- app/assets/stylesheets/case_states.sass | 2 ++ app/views/cases/stats/show.html.haml | 33 +++++++++++++++---------- 2 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 app/assets/stylesheets/case_states.sass diff --git a/app/assets/stylesheets/case_states.sass b/app/assets/stylesheets/case_states.sass new file mode 100644 index 000000000..bdd48dd6c --- /dev/null +++ b/app/assets/stylesheets/case_states.sass @@ -0,0 +1,2 @@ +.stat-label + font-style: italic diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml index 87690a09e..e45be5b57 100644 --- a/app/views/cases/stats/show.html.haml +++ b/app/views/cases/stats/show.html.haml @@ -12,16 +12,23 @@ %div %h1.admin__title= t '.case_stats' - %ul - %li - Created: - = @case.created_at.strftime("%B %d, %Y") - %li - Published: - = @case.published_at.strftime("%B %d, %Y") - %li - Total Reads (signed-in users): - = @case.events.size - %li - Total Deployments: - = @case.deployments.size \ No newline at end of file + %div + %ul + %li + %span.stat-label Created: + = @case.created_at.strftime("%B %d, %Y") + %li + %span.stat-label Published: + = @case.published_at.strftime("%B %d, %Y") + %li + %span.stat-label Total Reads: + = @case.events.size + + %li + %span.stat-label Total Deployments: + = @case.deployments.size + .pt-callout.pt-icon-info-sign.form__callout + Totals only count users that were signed-in to Gala when viewing the case. + + %table + From ed05c66742f4557b0b09fc2e659b3cbae8c479f5 Mon Sep 17 00:00:00 2001 From: Alex Fichter Date: Tue, 6 Feb 2024 16:47:03 -0500 Subject: [PATCH 06/13] wip, table --- app/helpers/cases_helper.rb | 10 ++++++ app/views/cases/stats/show.html.haml | 49 +++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/app/helpers/cases_helper.rb b/app/helpers/cases_helper.rb index 63007dd91..a4dd2a1ad 100644 --- a/app/helpers/cases_helper.rb +++ b/app/helpers/cases_helper.rb @@ -11,4 +11,14 @@ def translators_string(c) def cases_as_json(cases) array = cases.map { |c| raw render partial: 'cases/case', formats: [:json], locals: { c: c } } end + + def duration(cases) + if cases.present? + time = cases.select("properties->>'duration' as duration")&.map{|r|r.duration.to_i}&.map{|d|d/60}&.then { |a| a.sum.to_f / a.size }.round + "#{time} seconds" + else + "NA" + end + + end end diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml index e45be5b57..0b9716c27 100644 --- a/app/views/cases/stats/show.html.haml +++ b/app/views/cases/stats/show.html.haml @@ -23,10 +23,57 @@ %li %span.stat-label Total Reads: = @case.events.size - %li %span.stat-label Total Deployments: = @case.deployments.size + + %table.admin__table.pt-html-table + %thead + %tr + %th(scope="col")='Event' + %th(scope="col")='All Time' + %th(scope="col")='Last Year' + %th(scope="col")='Last 6 Months' + %th(scope="col")='Avg Visit Duration' + %tbody + %tr + %td Reader Visits Case Overview + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 12.months.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 6.months.ago..).size + %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'read_overview')) + %tr + %td Reader Reads a Card + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 12.months.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 6.months.ago..).size + %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'read_card')) + %tr + %td Reader Engages With Endnote + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 12.months.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 6.months.ago..).size + %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote')) + %tr + %td Reader listens to a podcast + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 12.months.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 6.months.ago..).size + %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast')) + %tr + %td Reader visits a CaseElement page + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 12.months.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 6.months.ago..).size + %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'visit_element')) + %tr + %td Reader reads a quiz + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 12.months.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 6.months.ago..).size + %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz')) + + .pt-callout.pt-icon-info-sign.form__callout Totals only count users that were signed-in to Gala when viewing the case. From 0e4d270dea67780176aaf96fea6cd5f35688ff6a Mon Sep 17 00:00:00 2001 From: Alex Fichter Date: Mon, 12 Feb 2024 08:23:06 -0500 Subject: [PATCH 07/13] additional wip --- app/helpers/cases_helper.rb | 10 --- app/views/cases/stats/show.html.haml | 92 +++++++++++++++------------- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/app/helpers/cases_helper.rb b/app/helpers/cases_helper.rb index a4dd2a1ad..63007dd91 100644 --- a/app/helpers/cases_helper.rb +++ b/app/helpers/cases_helper.rb @@ -11,14 +11,4 @@ def translators_string(c) def cases_as_json(cases) array = cases.map { |c| raw render partial: 'cases/case', formats: [:json], locals: { c: c } } end - - def duration(cases) - if cases.present? - time = cases.select("properties->>'duration' as duration")&.map{|r|r.duration.to_i}&.map{|d|d/60}&.then { |a| a.sum.to_f / a.size }.round - "#{time} seconds" - else - "NA" - end - - end end diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml index 0b9716c27..46e38bd54 100644 --- a/app/views/cases/stats/show.html.haml +++ b/app/views/cases/stats/show.html.haml @@ -17,65 +17,73 @@ %li %span.stat-label Created: = @case.created_at.strftime("%B %d, %Y") + %li + %span.stat-label Updated: + = @case.updated_at.strftime("%B %d, %Y") %li %span.stat-label Published: = @case.published_at.strftime("%B %d, %Y") - %li - %span.stat-label Total Reads: - = @case.events.size - %li - %span.stat-label Total Deployments: - = @case.deployments.size %table.admin__table.pt-html-table %thead %tr %th(scope="col")='Event' - %th(scope="col")='All Time' - %th(scope="col")='Last Year' + %th(scope="col")='Last Seven Days' %th(scope="col")='Last 6 Months' - %th(scope="col")='Avg Visit Duration' + %th(scope="col")='Last Year' + %th(scope="col")='All Time' %tbody %tr - %td Reader Visits Case Overview - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 12.months.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 6.months.ago..).size - %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'read_overview')) + %td Deployed + %td= @case.deployments.where(created_at: 7.days.ago..).size + %td= @case.deployments.where(created_at: 6.months.ago..).size + %td= @case.deployments.where(created_at: 12.months.ago..).size + %td= @case.deployments.size %tr - %td Reader Reads a Card - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 12.months.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 6.months.ago..).size - %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'read_card')) + %td Total Reader Activity + %td= Ahoy::Event.for_case(@case).where(time: 7.days.ago..).size + %td= Ahoy::Event.for_case(@case).where(time: 6.months.ago..).size + %td= Ahoy::Event.for_case(@case).where(time: 12.months.ago..).size + %td= Ahoy::Event.for_case(@case).size %tr - %td Reader Engages With Endnote - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 12.months.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 6.months.ago..).size - %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote')) + %td Reader Visits Case Overview + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 7.days.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 6.months.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 12.months.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').size %tr - %td Reader listens to a podcast - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 12.months.ago..).size + %td Reader Listens to a podcast + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 7.days.ago..).size %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 6.months.ago..).size - %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast')) - %tr - %td Reader visits a CaseElement page - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 12.months.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 6.months.ago..).size - %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'visit_element')) - %tr - %td Reader reads a quiz - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 12.months.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 6.months.ago..).size - %td= duration(Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz')) - + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 12.months.ago..).size + %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').size + -# %tr + -# %td Visits a CaseElement page + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 7.days.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 6.months.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 12.months.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').size + -# %tr + -# %td Reads a quiz + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 7.days.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 6.months.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 12.months.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').size + -# %tr + -# %td Reads a Card + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 7.days.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 6.months.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 12.months.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').size + -# %tr + -# %td Engages With Endnote + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 7.days.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 6.months.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 12.months.ago..).size + -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').size .pt-callout.pt-icon-info-sign.form__callout - Totals only count users that were signed-in to Gala when viewing the case. + Totals only count non-admin users that were signed-in to Gala when viewing the case. %table From c5f2be806a7c363c56b88ca02d3dbce7c39014c0 Mon Sep 17 00:00:00 2001 From: Alex Fichter Date: Mon, 12 Feb 2024 08:28:08 -0500 Subject: [PATCH 08/13] tweak --- app/views/cases/stats/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml index 46e38bd54..92d825386 100644 --- a/app/views/cases/stats/show.html.haml +++ b/app/views/cases/stats/show.html.haml @@ -83,7 +83,7 @@ -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').size .pt-callout.pt-icon-info-sign.form__callout - Totals only count non-admin users that were signed-in to Gala when viewing the case. + Totals only count users that were signed-in to Gala when viewing the case. %table From 5f862ef46c9dbda883a1cd12e386194e17589453 Mon Sep 17 00:00:00 2001 From: waisaed Date: Mon, 26 Feb 2024 10:35:01 -0500 Subject: [PATCH 09/13] stats label tweaks --- app/views/cases/stats/show.html.haml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml index 92d825386..16316be9c 100644 --- a/app/views/cases/stats/show.html.haml +++ b/app/views/cases/stats/show.html.haml @@ -17,24 +17,24 @@ %li %span.stat-label Created: = @case.created_at.strftime("%B %d, %Y") - %li - %span.stat-label Updated: - = @case.updated_at.strftime("%B %d, %Y") %li %span.stat-label Published: = @case.published_at.strftime("%B %d, %Y") + %li + %span.stat-label Last Updated: + = @case.updated_at.strftime("%B %d, %Y") %table.admin__table.pt-html-table %thead %tr - %th(scope="col")='Event' + %th(scope="col")='Activity' %th(scope="col")='Last Seven Days' - %th(scope="col")='Last 6 Months' - %th(scope="col")='Last Year' + %th(scope="col")='Last Six Months' + %th(scope="col")='Last 12 Months' %th(scope="col")='All Time' %tbody %tr - %td Deployed + %td Deployments %td= @case.deployments.where(created_at: 7.days.ago..).size %td= @case.deployments.where(created_at: 6.months.ago..).size %td= @case.deployments.where(created_at: 12.months.ago..).size @@ -46,13 +46,13 @@ %td= Ahoy::Event.for_case(@case).where(time: 12.months.ago..).size %td= Ahoy::Event.for_case(@case).size %tr - %td Reader Visits Case Overview + %td Case Overview Visits %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 7.days.ago..).size %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 6.months.ago..).size %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 12.months.ago..).size %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').size %tr - %td Reader Listens to a podcast + %td Podcast Listens %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 7.days.ago..).size %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 6.months.ago..).size %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 12.months.ago..).size @@ -83,7 +83,7 @@ -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').size .pt-callout.pt-icon-info-sign.form__callout - Totals only count users that were signed-in to Gala when viewing the case. + Totals only count users that were signed-in to Gala when viewing the case. Readers' browser settings may impact the accuracy of these counts. %table From cb32dd260c0b05da212521178149e44915fde9f0 Mon Sep 17 00:00:00 2001 From: Alex Fichter Date: Mon, 4 Mar 2024 10:21:19 -0500 Subject: [PATCH 10/13] additional wip, podcasts, unique visits --- app/views/cases/stats/show.html.haml | 57 +++++++++------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml index 16316be9c..0027a6d54 100644 --- a/app/views/cases/stats/show.html.haml +++ b/app/views/cases/stats/show.html.haml @@ -40,47 +40,26 @@ %td= @case.deployments.where(created_at: 12.months.ago..).size %td= @case.deployments.size %tr - %td Total Reader Activity - %td= Ahoy::Event.for_case(@case).where(time: 7.days.ago..).size - %td= Ahoy::Event.for_case(@case).where(time: 6.months.ago..).size - %td= Ahoy::Event.for_case(@case).where(time: 12.months.ago..).size - %td= Ahoy::Event.for_case(@case).size + %td Unique Visits to a CaseElement page (any page beyond the overview) + %td= @case.events.interesting.where_properties(name: 'visit_element').where(time: 7.days.ago..).group(:user_id).count.keys.count + %td= @case.events.interesting.where_properties(name: 'visit_element').where(time: 6.months.ago..).group(:user_id).count.keys.count + %td= @case.events.interesting.where_properties(name: 'visit_element').where(time: 12.months.ago..).group(:user_id).count.keys.count + %td= @case.events.interesting.where_properties(name: 'visit_element').group(:user_id).count.keys.count %tr %td Case Overview Visits - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 7.days.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 6.months.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').where(time: 12.months.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_overview').size - %tr - %td Podcast Listens - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 7.days.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 6.months.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').where(time: 12.months.ago..).size - %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_podcast').size - -# %tr - -# %td Visits a CaseElement page - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 7.days.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 6.months.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').where(time: 12.months.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_element').size - -# %tr - -# %td Reads a quiz - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 7.days.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 6.months.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').where(time: 12.months.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_quiz').size - -# %tr - -# %td Reads a Card - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 7.days.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 6.months.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').where(time: 12.months.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'read_card').size - -# %tr - -# %td Engages With Endnote - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 7.days.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 6.months.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').where(time: 12.months.ago..).size - -# %td= Ahoy::Event.for_case(@case).where_properties(name: 'visit_edgenote').size + %td= @case.events.interesting.where_properties(name: 'read_overview').where(time: 7.days.ago..).size + %td= @case.events.interesting.where_properties(name: 'read_overview').where(time: 6.months.ago..).size + %td= @case.events.interesting.where_properties(name: 'read_overview').where(time: 12.months.ago..).size + %td= @case.events.interesting.where_properties(name: 'read_overview').size + + - @case.podcasts.each do |podcast| + - podcast_listen_events = Ahoy::Event.interesting.where_properties(podcast_id: podcast.id) + %tr + %td Podcast Listen - #{podcast.title} + %td= podcast_listen_events.where(time: 7.days.ago..).size + %td= podcast_listen_events.where(time: 6.months.ago..).size + %td= podcast_listen_events.where(time: 12.months.ago..).size + %td= podcast_listen_events.size .pt-callout.pt-icon-info-sign.form__callout Totals only count users that were signed-in to Gala when viewing the case. Readers' browser settings may impact the accuracy of these counts. From 79475942155a4f227522d87810d111c1c3c4c1e4 Mon Sep 17 00:00:00 2001 From: waisaed Date: Tue, 30 Apr 2024 13:02:23 -0400 Subject: [PATCH 11/13] add translations and remove overview visits --- app/views/cases/stats/show.html.haml | 23 ++++++++--------------- config/locales/en.yml | 12 +++++++++++- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml index 0027a6d54..94bccbc89 100644 --- a/app/views/cases/stats/show.html.haml +++ b/app/views/cases/stats/show.html.haml @@ -15,13 +15,13 @@ %div %ul %li - %span.stat-label Created: + %span.stat-label= t '.created' = @case.created_at.strftime("%B %d, %Y") %li - %span.stat-label Published: + %span.stat-label= t '.published' = @case.published_at.strftime("%B %d, %Y") %li - %span.stat-label Last Updated: + %span.stat-label= t '.last_updated' = @case.updated_at.strftime("%B %d, %Y") %table.admin__table.pt-html-table @@ -34,35 +34,28 @@ %th(scope="col")='All Time' %tbody %tr - %td Deployments + %td= t '.deployments' %td= @case.deployments.where(created_at: 7.days.ago..).size %td= @case.deployments.where(created_at: 6.months.ago..).size %td= @case.deployments.where(created_at: 12.months.ago..).size %td= @case.deployments.size %tr - %td Unique Visits to a CaseElement page (any page beyond the overview) + %td= t '.visits' %td= @case.events.interesting.where_properties(name: 'visit_element').where(time: 7.days.ago..).group(:user_id).count.keys.count %td= @case.events.interesting.where_properties(name: 'visit_element').where(time: 6.months.ago..).group(:user_id).count.keys.count %td= @case.events.interesting.where_properties(name: 'visit_element').where(time: 12.months.ago..).group(:user_id).count.keys.count %td= @case.events.interesting.where_properties(name: 'visit_element').group(:user_id).count.keys.count - %tr - %td Case Overview Visits - %td= @case.events.interesting.where_properties(name: 'read_overview').where(time: 7.days.ago..).size - %td= @case.events.interesting.where_properties(name: 'read_overview').where(time: 6.months.ago..).size - %td= @case.events.interesting.where_properties(name: 'read_overview').where(time: 12.months.ago..).size - %td= @case.events.interesting.where_properties(name: 'read_overview').size - + - @case.podcasts.each do |podcast| - podcast_listen_events = Ahoy::Event.interesting.where_properties(podcast_id: podcast.id) %tr - %td Podcast Listen - #{podcast.title} + %td= t ('.podcast_listens'), podcast_title: podcast.title %td= podcast_listen_events.where(time: 7.days.ago..).size %td= podcast_listen_events.where(time: 6.months.ago..).size %td= podcast_listen_events.where(time: 12.months.ago..).size %td= podcast_listen_events.size - .pt-callout.pt-icon-info-sign.form__callout - Totals only count users that were signed-in to Gala when viewing the case. Readers' browser settings may impact the accuracy of these counts. + .pt-callout.pt-icon-info-sign.form__callout= t '.disclaimer' %table diff --git a/config/locales/en.yml b/config/locales/en.yml index 33484eb6d..11d34afb2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -264,6 +264,16 @@ en: stats: show: case_stats: Case Stats + created: Created + published: "Published:" + last_updated: "Last Updated:" + deployments: "Deployments" + visits: Unique Visits + podcast_listens: Podcast Listens - %{podcast_title} + disclaimer: > + Totals count only users that were signed-in to Gala when viewing the case. + 'Unique Visits' counts readers who viewed a page beyond the overview page of your case. + Readers' browser settings may impact the accuracy of these counts. settings: edit: change_library: Change library @@ -834,7 +844,7 @@ en: my_cases: index: case_stats: Case Stats - confirm_delete: > + confirm_delete: Are you sure you wish to delete this case? This action cannot be undone. create_a_case: Create a Case delete_case: Delete case. From 39627aedc25de3cff03d4d669d81900c6cb41c1f Mon Sep 17 00:00:00 2001 From: Alex Fichter Date: Wed, 8 May 2024 13:09:11 -0400 Subject: [PATCH 12/13] summarizes the locales of the unique users and translates --- app/helpers/cases_helper.rb | 11 +++++++++++ app/views/cases/stats/show.html.haml | 7 ++++++- config/locales/en.yml | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/helpers/cases_helper.rb b/app/helpers/cases_helper.rb index 63007dd91..7c72dc36d 100644 --- a/app/helpers/cases_helper.rb +++ b/app/helpers/cases_helper.rb @@ -11,4 +11,15 @@ def translators_string(c) def cases_as_json(cases) array = cases.map { |c| raw render partial: 'cases/case', formats: [:json], locals: { c: c } } end + + def locales_to_sentence(locales = []) + if locales.present? + locales.map{|locale| + Translation.language_name(locale) + }.sort.to_sentence + else + "Unknown" + end + + end end diff --git a/app/views/cases/stats/show.html.haml b/app/views/cases/stats/show.html.haml index 94bccbc89..b3c08ea84 100644 --- a/app/views/cases/stats/show.html.haml +++ b/app/views/cases/stats/show.html.haml @@ -45,7 +45,12 @@ %td= @case.events.interesting.where_properties(name: 'visit_element').where(time: 6.months.ago..).group(:user_id).count.keys.count %td= @case.events.interesting.where_properties(name: 'visit_element').where(time: 12.months.ago..).group(:user_id).count.keys.count %td= @case.events.interesting.where_properties(name: 'visit_element').group(:user_id).count.keys.count - + %tr + %td= t '.locales' + %td= locales_to_sentence(Reader.where(id: @case.events.interesting.where_properties(name: 'visit_element').where(time: 7.days.ago..).group(:user_id).count.keys).pluck(:locale)) + %td= locales_to_sentence(Reader.where(id: @case.events.interesting.where_properties(name: 'visit_element').where(time: 6.months.ago..).group(:user_id).count.keys).pluck(:locale)) + %td= locales_to_sentence(Reader.where(id: @case.events.interesting.where_properties(name: 'visit_element').where(time: 12.months.ago..).group(:user_id).count.keys).pluck(:locale)) + %td= locales_to_sentence(Reader.where(id: @case.events.interesting.where_properties(name: 'visit_element').group(:user_id).count.keys).pluck(:locale)) - @case.podcasts.each do |podcast| - podcast_listen_events = Ahoy::Event.interesting.where_properties(podcast_id: podcast.id) %tr diff --git a/config/locales/en.yml b/config/locales/en.yml index 11d34afb2..b39ba22d5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -269,6 +269,7 @@ en: last_updated: "Last Updated:" deployments: "Deployments" visits: Unique Visits + locales: Locales podcast_listens: Podcast Listens - %{podcast_title} disclaimer: > Totals count only users that were signed-in to Gala when viewing the case. From 3aeb7b6b242eec09ea7f99c6ff2f65856d920d9b Mon Sep 17 00:00:00 2001 From: Alex Fichter Date: Wed, 8 May 2024 13:31:03 -0400 Subject: [PATCH 13/13] tweak --- app/helpers/cases_helper.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/helpers/cases_helper.rb b/app/helpers/cases_helper.rb index 7c72dc36d..14c8afdb6 100644 --- a/app/helpers/cases_helper.rb +++ b/app/helpers/cases_helper.rb @@ -15,10 +15,15 @@ def cases_as_json(cases) def locales_to_sentence(locales = []) if locales.present? locales.map{|locale| - Translation.language_name(locale) - }.sort.to_sentence + tr = Translation.language_name(locale) + if tr + "#{tr} (#{locale})" + else + "" + end + }&.compact&.to_sentence else - "Unknown" + "" end end