Skip to content
Snippets Groups Projects
Verified Commit de1b8dc2 authored by tribut's avatar tribut :man_dancing:
Browse files

Add function to compare local and engelsystem assignments

parent 95e9e5f3
No related branches found
No related tags found
No related merge requests found
Pipeline #36884 passed
......@@ -67,4 +67,33 @@ class Conference < ApplicationRecord
return nil
end
end
def compare_engelsystem_shifts(additional_conferences = [])
return unless translation_angel_id = fetch_translation_angel_id
return unless data = fetch_engelsystem("angeltypes/#{translation_angel_id}/shifts")
engelsystem_shifts = data.each_with_object({}) do |shift, hash|
hash[shift['id']] = shift
&.dig("needed_angel_types")
&.find{ |t| t["angel_type"]["id"] == translation_angel_id }
&.dig("entries")
&.map{ |t| t["user"]["name"] }
end
Session.where(conference: [self]+additional_conferences).includes(:assignments).each do |session|
next if session.engelsystem_id.blank?
engelsystem_assigned = engelsystem_shifts[session.engelsystem_id]
local_assigned = session.assignments.includes(:user).map{|a|a.user.name}
only_engelsystem = engelsystem_assigned - local_assigned
only_local = local_assigned - engelsystem_assigned
unless only_engelsystem.blank? and only_local.blank?
puts "============================="
puts "Session: #{session.title} (#{session.engelsystem_id})"
puts "============================="
puts "Not signed up in engelsystem: #{only_local.join(", ")}" unless only_local.blank?
puts "Missing in local assignments: #{only_engelsystem.join(", ")}" unless only_engelsystem.blank?
puts
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment