Skip to content

Commit

Permalink
Add dormant/active chapter counts to districts
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenyeargin committed Feb 3, 2024
1 parent 6224e88 commit bff0721
Show file tree
Hide file tree
Showing 5 changed files with 3,621 additions and 2,165 deletions.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
3 changes: 3 additions & 0 deletions app/models/chapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class Chapter < ApplicationRecord
belongs_to :district, optional: true
validates_presence_of :name

scope :active, -> { where(status: 1) }
scope :inactive, -> { where(status: 0) }

include GenerateCsv

def institution_name=(val)
Expand Down
6 changes: 4 additions & 2 deletions app/views/admin/districts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<th>District</th>
<th>Short Name</th>
<th>District Governor</th>
<th>Chapter Count</th>
<th>Active Chapters</th>
<th>Dormant Chapters</th>
<th>Total Manpower</th>
</thead>
<tbody>
Expand All @@ -25,7 +26,8 @@
<td data-order="<%= district.position %>"><%= link_to district.name, admin_district_path(district) %></td>
<td><%= district.short_name %></td>
<td><%= district.staff_name %></td>
<td class="text-end"><%= district.chapters.length %></td>
<td class="text-end"><%= district.chapters.active.length %></td>
<td class="text-end"><%= district.chapters.inactive.length %></td>
<td class="text-end"><%= district.chapters.sum(:manpower) %></td>
</tr>
<% end %>
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "app",
"private": "true",
"dependencies": {
"@hotwired/stimulus": "^3.2.1",
"@hotwired/turbo-rails": "^7.3.0",
Expand Down
Loading

0 comments on commit bff0721

Please sign in to comment.