-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1288 from SplitTime/oveson/lottery-calculations-d…
…etails Lottery calculations details
- Loading branch information
Showing
17 changed files
with
362 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
class Lotteries::Calculations::Base < ApplicationRecord | ||
include PgSearch::Model | ||
|
||
self.abstract_class = true | ||
|
||
enum gender: { | ||
male: 0, | ||
female: 1, | ||
nonbinary: 2, | ||
} | ||
|
||
pg_search_scope :person_search, | ||
associated_against: { | ||
person: [:first_name, :last_name, :city, :state_name, :country_name] | ||
} | ||
|
||
belongs_to :organization | ||
belongs_to :person | ||
|
||
delegate :bio, :flexible_geolocation, :name, to: :person | ||
|
||
def self.search_default_none(param) | ||
return none unless param && param.size > 2 | ||
|
||
person_search(param) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class Lotteries::Calculations::Hardrock2025 < ApplicationRecord | ||
class Lotteries::Calculations::Hardrock2025 < Lotteries::Calculations::Base | ||
# self.table_name must be set for a Lotteries::Calculations class to work | ||
self.table_name = :lotteries_calculations_hardrock_2025s | ||
|
||
enum gender: { | ||
male: 0, | ||
female: 1, | ||
nonbinary: 2, | ||
} | ||
|
||
belongs_to :organization | ||
belongs_to :person | ||
# self.primary_key must be set to :id for PgSearch to work | ||
# Also, the view must return an "id" column | ||
# Use select row_number() over () as id if no other unique id is available | ||
self.primary_key = :id | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<%# locals: (fact:) %> | ||
|
||
<tr class="align-middle"> | ||
<td><%= historical_fact_kind_badge(fact.kind) %></td> | ||
<td class="text-center"><%= fact.year %></td> | ||
<td class="text-center"><%= fact.quantity %></td> | ||
<td><%= fact.comments %></td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<%# locals: (record:) %> | ||
|
||
<%= turbo_frame_tag dom_id(record) do %> | ||
<div class="card bg-light mt-3"> | ||
<div class="card-header"> | ||
<div class="row"> | ||
<div class="col"> | ||
<h5 class="fw-bold"><%= record.name %></h5> | ||
<h6><%= record.flexible_geolocation %></h6> | ||
<h6><%= record.bio %></h6> | ||
</div> | ||
<div class="col text-end"> | ||
<h4><span class="badge bg-secondary"><%= record.division %></span></h4> | ||
<h6 class="fw-bold mb-4"><%= "#{pluralize(record.ticket_count, 'ticket')}" %></h6> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="card-body"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Kind</th> | ||
<th class="text-center">Year</th> | ||
<th class="text-center">Quantity</th> | ||
<th>Comments</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<%= render partial: "historical_facts/calculations_row", collection: record.person.historical_facts.ordered, as: :fact %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<% end %> |
16 changes: 16 additions & 0 deletions
16
app/views/lotteries/_calculations_applicant_lookup.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<%# locals: (presenter:) -%> | ||
|
||
<%= form_tag calculations_organization_lottery_path(presenter.organization, presenter.lottery, anchor: "applicant_lookup_input"), | ||
class: "w-100", | ||
method: :get do %> | ||
<div id="applicant_lookup_input" class="input-group"> | ||
<%= text_field_tag "filter[search]", | ||
prepared_params[:search], | ||
placeholder: "Find an applicant", | ||
autofocus: true, | ||
class: "form-control search-box" %> | ||
<%= button_tag(type: :submit, id: "calculations-applicant-lookup-submit", class: "btn btn-primary input-group-text") do %> | ||
<i class="fas fa-search"></i> | ||
<% end %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<%# locals: (presenter:) %> | ||
|
||
<div class="card mt-4"> | ||
<div class="card-header"> | ||
<div class="row"> | ||
<div class="col"> | ||
<h2 class="fw-bold">By Division</h2> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="card-body table-responsive"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th class="text-center">Entrants</th> | ||
<th class="text-center">%</th> | ||
<th class="text-center">Tickets</th> | ||
<th class="text-center">%</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% presenter.division_calculations.each do |calc| %> | ||
<tr> | ||
<td><%= calc.name %></td> | ||
<td class="text-center"><%= calc.entrants_count %></td> | ||
<th class="text-center"><%= "#{(calc.entrants_count / presenter.division_entrants_count.to_f * 100).round(1)}%" %></th> | ||
<td class="text-center"><%= calc.tickets_count %></td> | ||
<th class="text-center"><%= "#{(calc.tickets_count / presenter.division_tickets_count.to_f * 100).round(1)}%" %></th> | ||
</tr> | ||
<% end %> | ||
<tr class="fw-bold bg-light"> | ||
<td>Totals</td> | ||
<td class="text-center"><%= presenter.division_entrants_count %></td> | ||
<th class="text-center">100.0%</th> | ||
<td class="text-center"><%= presenter.division_tickets_count %></td> | ||
<th class="text-center">100.0%</th> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<%# locals: (presenter:) %> | ||
|
||
<div class="card mt-4"> | ||
<div class="card-header"> | ||
<div class="row"> | ||
<div class="col"> | ||
<h2 class="fw-bold">By Gender</h2> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="card-body table-responsive"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th class="text-center">Entrants</th> | ||
<th class="text-center">%</th> | ||
<th class="text-center">Tickets</th> | ||
<th class="text-center">%</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% presenter.gender_calculations.each do |calc| %> | ||
<tr> | ||
<td><%= calc.name.titleize %></td> | ||
<td class="text-center"><%= calc.entrants_count %></td> | ||
<th class="text-center"><%= "#{(calc.entrants_count / presenter.gender_entrants_count.to_f * 100).round(1)}%" %></th> | ||
<td class="text-center"><%= calc.tickets_count %></td> | ||
<th class="text-center"><%= "#{(calc.tickets_count / presenter.gender_tickets_count.to_f * 100).round(1)}%" %></th> | ||
</tr> | ||
<% end %> | ||
<tr class="fw-bold bg-light"> | ||
<td>Totals</td> | ||
<td class="text-center"><%= presenter.gender_entrants_count %></td> | ||
<th class="text-center">100.0%</th> | ||
<td class="text-center"><%= presenter.gender_tickets_count %></td> | ||
<th class="text-center">100.0%</th> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.