From ef3d0186a58ecdc157baef05fda5386816f23dd7 Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Mon, 14 Jan 2019 13:40:56 -0500 Subject: [PATCH] propogate up valid_child_count for admin data --- app/views/categories/show.html.haml | 32 ++++++++--------------------- lib/tasks/data.rake | 12 +++++++++++ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/app/views/categories/show.html.haml b/app/views/categories/show.html.haml index d7927412..5b3042c2 100644 --- a/app/views/categories/show.html.haml +++ b/app/views/categories/show.html.haml @@ -15,30 +15,14 @@ %p= @category.description - if valid - %p - - if @school_category.response_count > 0 - %b Total Responses: - = number_with_delimiter(@school_category.response_count) - -       - - %b Average Response: - = @school_category.answer_index_average.round(1) - (out of 5) - - - if @school_category.response_count > 0 && @school_category.zscore.present? -       - - - if @school_category.zscore.present? - %b Administrative Data: - - if @school_category.nonlikert.present? - = @school_category.nonlikert - = "(Benchmark: #{@school_category.category.benchmark})" -   - - if @school_category.zscore.present? - = @school_category.zscore.round(1) + 3 - (out of 5) - + -# %p + -# - if @school_category.response_count > 0 + -# %b Average: + -# - likert = @school_category.answer_index_average + -# - zscore = @school_category.zscore.present? ? @school_category.zscore + 3 : nil + -# - likert = zscore if zscore.present? + -# - likert = likert.round(1) + -# = number_with_delimiter(likert) .indicator-container.py-3 = render 'school_categories/indicator', info: @school_category diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 7c7aec51..0893e46d 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -382,6 +382,18 @@ namespace :data do valid_child_count: 1 ) end + + pc = nonlikert_category.parent_category + while pc != nil + psc = SchoolCategory.for(school, pc).in(school_category.year).first + if psc != nil + psc.update(valid_child_count: (psc.valid_child_count || 0) + 1) + pc = pc.parent_category + else + pc = nil + end + end + end ENV.delete('BULK_PROCESS')