Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/assets/stylesheets/pages/certification/ships/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,22 @@
gap: var(--space-xs);
}

// Category tag on a queue row (e.g. Hackpad) — a pill, not a status.
&__tag {
display: inline-flex;
align-items: center;
padding: 1px 8px;
border-radius: 999px;
font-size: 0.72rem;
font-weight: 700;
white-space: nowrap;

&--hackpad {
background: rgba(235, 183, 255, 0.18);
color: var(--color-brand-lilac);
}
}

// Submitter, relative age, and the claim flag all share one meta line under
// the project title — keeps the table to three columns with no dead space.
&__project-meta {
Expand Down
19 changes: 19 additions & 0 deletions app/controllers/admin/certification/funding_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def index
@status = params[:status].presence_in(%w[pending approved returned all]) || "pending"
@sort = params[:sort] == "newest" ? "newest" : "oldest"
@search = params[:search].to_s.strip
@project_kind = params[:project_kind].presence_in(%w[all hackpad]) || "all"
@from = parse_date(params[:from])
@to = parse_date(params[:to])

Expand All @@ -19,11 +20,19 @@ def index
scope = scope.where("certification_funding_requests.created_at >= ?", @from.beginning_of_day) if @from
scope = scope.where("certification_funding_requests.created_at <= ?", @to.end_of_day) if @to
scope = apply_search(scope) if @search.present?
scope = scope.where(project_id: hackpad_project_ids) if @project_kind == "hackpad"

@pagy, @funding_requests = pagy(:offset,
scope.order(created_at: @sort == "newest" ? :desc : :asc),
limit: 25)

# Which of the displayed rows are Hackpad projects (one query, so the view
# can flag them without an N+1 of Project#current_mission per row).
@hackpad_project_ids = hackpad_project_ids
.where(project_id: @funding_requests.map(&:project_id))
.pluck(:project_id)
.to_set

@stats = ::Certification::FundingRequest.dashboard_stats
@lb_period = params[:lb].presence_in(%w[daily weekly alltime]) || "daily"
@leaderboards = {
Expand Down Expand Up @@ -77,6 +86,16 @@ def set_funding_request
@funding_request = ::Certification::FundingRequest.find(params[:id])
end

# Project ids whose current (active, non-detached) mission is the Hackpad
# mission — i.e. "hackpad projects" (mirrors Project#current_mission, which a
# project has at most one of). Used to filter the funding queue.
def hackpad_project_ids
Project::MissionAttachment.active
.joins(:mission)
.where(missions: { slug: "hackpad" })
.select(:project_id)
end

# Both fetches below fan out to live HTTP (per Hackatime key / Lookout session)
# on every render, including the re-render after a failed verdict submit. The
# provider URLs only expire after ~1h, so a short cache keyed by project kills
Expand Down
17 changes: 16 additions & 1 deletion app/views/admin/certification/funding_requests/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@
id: "filter-status", class: "ship-queue__select",
data: { action: "change->certification--queue#submit" } %>
</div>
<div class="ship-queue__filter">
<label for="filter-project-kind">Project</label>
<%= select_tag :project_kind,
options_for_select([["All projects", "all"], ["Hackpad", "hackpad"]], @project_kind),
id: "filter-project-kind", class: "ship-queue__select",
data: { action: "change->certification--queue#submit" } %>
</div>
<div class="ship-queue__filter">
<label for="filter-sort">Sort</label>
<%= select_tag :sort,
Expand Down Expand Up @@ -198,6 +205,9 @@
<div class="ship-queue__project-head">
<%= link_to fr.project.title, admin_certification_funding_request_path(fr), class: "ship-queue__project-title" %>
<span class="ship-queue__project-id">#<%= fr.id %></span>
<% if @hackpad_project_ids.include?(fr.project_id) %>
<span class="ship-queue__tag ship-queue__tag--hackpad">Hackpad</span>
<% end %>
</div>
<div class="ship-queue__project-meta">
<span>by <%= owner&.display_name || "—" %></span>
Expand Down Expand Up @@ -228,7 +238,12 @@
<% owner = fr.project.memberships.find(&:owner?)&.user %>
<%= link_to admin_certification_funding_request_path(fr), class: "ship-queue__card" do %>
<div class="ship-queue__card-top">
<span class="ship-queue__project-title"><%= fr.project.title %></span>
<span class="ship-queue__project-title">
<%= fr.project.title %>
<% if @hackpad_project_ids.include?(fr.project_id) %>
<span class="ship-queue__tag ship-queue__tag--hackpad">Hackpad</span>
<% end %>
</span>
<span class="status-pill status-pill--<%= fr.status %>"><%= fr.status.capitalize %></span>
</div>
<div class="ship-queue__project-meta">
Expand Down