Skip to content

Commit

Permalink
Merged main
Browse files Browse the repository at this point in the history
  • Loading branch information
Pamela Glickman authored and Pamela Glickman committed Sep 16, 2024
1 parent c983c3e commit 9db873c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/regions/challenges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def challenge_params
params.require(:challenge).permit(
:name, :short_desc, :long_desc, :eligibility, :video_url, :approved,
:banner_image, :image, :pdf, :pdf_preview, :nation_wide, :teaser,
:outcome_expectations, :sponsor_values
:outcome_expectations, :sponsor_values,
)
end
end
3 changes: 1 addition & 2 deletions app/controllers/challenges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ def check_competition_start!
@challenge = Challenge.find_by identifier: params[:identifier]
@challenge = Challenge.find(params[:identifier]) if @challenge.nil?
@region = @challenge.region
return if @region.is_show == 1 || @competition.started?(@region.time_zone) ||
return if @region.is_show == 1 || @competition.started?(@region.time_zone) ||
(@region.international? && @competition.started?(FIRST_COMPETITION_TIME_ZONE))


flash[:alert] = 'Challenges will become visible at the start of the competition'
redirect_to root_path
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/regions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def check_show
end

def eligible_locations
#@eligible_locations = [
# @eligible_locations = [
# {label: 'NSW', path: 'new_south_wales_2024'},
# {label: 'QLD', path: 'queensland_2024'},
# {label: 'VIC', path: 'victoria_2024'},
Expand All @@ -91,16 +91,15 @@ def eligible_locations
# {label: 'Australia', path: 'australia2024'},
# {label: 'New Zealand', path: 'new_zealand2024'},
# {label: 'International', path: 'international_2024'},
#]
# ]

regions = @competition.regions.order(:category, :name)

@eligible_locations = regions.map do |region|
{
label: region.name,
path: region.identifier
path: region.identifier,
}
end

end
end
2 changes: 1 addition & 1 deletion app/models/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def average_score
total_score += score
voted += 1
end
return (total_score / voted) unless voted.zero?
(total_score / voted) unless voted.zero?
end

# Returns a count of the number of judges that have completed votes for an
Expand Down
11 changes: 4 additions & 7 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,12 @@ def available_checkpoints(challenge)
# taking into only challenges already entered.
# ENHANCEMENT: Move to controller or helper.
def admin_available_checkpoints(_challenge)
valid_checkpoints = []
competition.checkpoints.each do |checkpoint|
competition.checkpoints.map do |checkpoint|
# ERROR: Not working correctly at the moment
# next if checkpoint.limit_reached?(self, challenge_region)

valid_checkpoints << checkpoint
checkpoint
end
valid_checkpoints
end

# Returns true if all the checkpoints have passed for a given team. false
Expand Down Expand Up @@ -179,10 +177,9 @@ def available_challenges(challenge_type)
# for.
# ENHANCEMENT: Move to active record query.
def member_competition_events
events = []
comp = competition
confirmed_members.each do |user|
events << user.participating_competition_event(comp)
events = confirmed_members.map do |user|
user.participating_competition_event(comp)
end
events.uniq
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def category
return 'Participant' if participant?
return 'Mentor' if mentor?
return 'Industry' if industry?
return 'Support' if support?

'Support' if support?
end

enum region: {
Expand Down
3 changes: 2 additions & 1 deletion app/services/demographics_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def initialize(competition, fieldtype)
@profiles = @competition.profiles.preload(:employment_status).compact
end

def report # rubocop:disable
# rubocop:disable
def report
grouped_data = case @fieldtype
when 'age'
@profiles.group_by(&:age)
Expand Down
11 changes: 4 additions & 7 deletions app/services/mailing_list_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,22 @@ def to_csv
def to_csv_by_date
CSV.generate do |csv|
csv << (USER_COLUMNS2 + ['region'])

# Collect all users across all regions
all_users = competition.regions.flat_map do |region|
region_users_all(region)
end.uniq

# Sort users by ID in descending order
sorted_users = all_users.sort_by(&:id).reverse

# Write sorted users to CSV
sorted_users.each do |user|
# Assuming you still want to include the region for each user
region_name = competition.regions.find { |region| region_users_all(region).include?(user) }&.name
csv << (user.attributes.values_at(*USER_COLUMNS2) + [region_name])
end
end

end

private
Expand All @@ -62,8 +61,6 @@ def region_users(region)
end

def region_users_all(region)
region.events.preload(:users).map do |event|
event.users
end.flatten.uniq
region.events.preload(:users).map(&:users).flatten.uniq
end
end

0 comments on commit 9db873c

Please sign in to comment.