trying to fix syncing

pull/1/head
Jared Cosulich 6 years ago
parent 619e7f3ac1
commit 26cb9c5bb3

@ -16,7 +16,7 @@ class CategoriesController < ApplicationController
school_categories = SchoolCategory.for(@school, @category)
@years = school_categories.map(&:year).map(&:to_i).sort
@year = (params[:year] || @years.first || "2018").to_i
@year = (params[:year] || @years.first || "2019").to_i
@years.delete(@year)
if school_categories.empty?

@ -19,7 +19,7 @@ class SchoolsController < ApplicationController
end
@years = @school_categories.map(&:year).map(&:to_i).sort.uniq
@year = (params[:year] || @years.last || "2018").to_i
@year = (params[:year] || @years.last || "2019").to_i
@years.delete(@year)
missing_categories = @categories - @school_categories.map(&:category)

@ -55,11 +55,14 @@ class SchoolCategory < ApplicationRecord
def chained_aggregated_responses
_aggregated_responses = aggregated_responses
child_school_categories = category.child_categories.collect do |cc|
SchoolCategory.for(school, cc).in(year).valid
end.flatten.compact
child_school_categories = []
if category.child_categories.length > 0
child_school_categories = category.child_categories.collect do |cc|
SchoolCategory.for(school, cc).in(year).valid
end.flatten.compact
return {} if child_school_categories.blank?
return {} if child_school_categories.blank?
end
average_zscore = nil
zscore_categories = child_school_categories.select { |csc| csc.zscore.present? && !csc.zscore.nan? }

File diff suppressed because one or more lines are too long

@ -223,7 +223,7 @@ namespace :data do
'teacher'
]
csv_string = File.read(File.expand_path('../../../data/MeasureKey2018.csv', __FILE__))
csv_string = File.read(File.expand_path('../../../data/MeasureKey2019.csv', __FILE__))
csv = CSV.parse(csv_string, :headers => true)
t = Time.new
@ -310,6 +310,7 @@ namespace :data do
t = Time.new
csv.each_with_index do |row, index|
next if index < startIndex
break if index > 100
if Time.new - startTime >= timeToRun || index > stopIndex
puts("ENDING #{timeToRun} SECONDS: #{Time.new - startTime} = #{startIndex} -> #{index} = #{index - startIndex} or #{(Time.new - t) / (index - startIndex)} per second")
@ -345,7 +346,7 @@ namespace :data do
next
end
respondent_id = "#{recipients}-#{index}-#{row["ResponseID"]}"
respondent_id = "#{recipients}-#{index}-#{row["ResponseId"]}"
recipient_id = respondent_map["#{school.id}-#{@year}-#{respondent_id}"]
if recipient_id.present?
recipient = school.recipients.where(id: recipient_id).first
@ -479,7 +480,7 @@ namespace :data do
next
end
school_category = school.school_categories.find_or_create_by(category: nonlikert_category, year: "2018")
school_category = school.school_categories.find_or_create_by(category: nonlikert_category, year: "2019")
if school_category.blank?
row["reason"] = "SCHOOL CATEGORY NOT FOUND: #{school.name} #{nonlikert_category.name}"
errors << row
@ -490,7 +491,7 @@ namespace :data do
school_category.update(
nonlikert: row["NL_Value"],
zscore: zscore.to_f,
year: "2018",
year: "2019",
valid_child_count: 1
)

Loading…
Cancel
Save