Skip to content
Open
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
13 changes: 13 additions & 0 deletions app/assets/stylesheets/pages/certification/ships/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,19 @@
}
}

&__bonus-tag {
display: inline-flex;
align-items: center;
padding: 1px 7px;
border-radius: 999px;
font-size: 0.7rem;
font-weight: 700;
letter-spacing: 0.02em;
white-space: nowrap;
background: rgba(255, 229, 100, 0.15);
color: var(--color-brand-yellow);
}

// --- Empty state -------------------------------------------------------
&__empty {
padding: var(--space-xl);
Expand Down
70 changes: 70 additions & 0 deletions app/assets/stylesheets/pages/certification/ships/_show.scss
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,76 @@
}
}

.bonus-stardust {
border-color: rgba(255, 229, 100, 0.25) !important;
background: rgba(255, 229, 100, 0.04) !important;

&__current {
margin: 0 0 var(--space-s);
font-size: 0.95rem;
color: var(--color-brand-yellow);
font-weight: 600;

strong {
font-weight: 800;
}
}

&__form {
margin-bottom: var(--space-xs);
}

&__field {
display: flex;
gap: var(--space-xs);
align-items: center;
}

&__input {
flex: 1;
padding: var(--space-xs) var(--space-s);
font-family: inherit;
font-size: var(--font-size-m);
font-variant-numeric: tabular-nums;
color: var(--color-space-text);
background: var(--color-space-surface, rgba(255, 255, 255, 0.04));
border: 1px solid rgba(255, 229, 100, 0.3);
border-radius: 8px;
appearance: textfield;

&:focus-visible {
outline: 2px solid var(--color-brand-yellow);
outline-offset: 1px;
}

&::-webkit-inner-spin-button,
&::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
}

&__breakdown {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: var(--space-s);
padding-top: var(--space-s);
border-top: 1px solid rgba(255, 229, 100, 0.15);
font-size: 0.85rem;
}

&__breakdown-label {
color: var(--color-space-text-muted, rgba(255, 255, 255, 0.5));
}

&__breakdown-value {
font-weight: 700;
color: var(--color-brand-yellow);
font-variant-numeric: tabular-nums;
}
}

@keyframes ship-review-pop {
0% {
transform: scale(1);
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/admin/certification/ships_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Admin::Certification::ShipsController < Admin::Certification::ApplicationController
before_action :release_other_claims, only: [ :next ]
before_action :set_ship, only: [ :show, :update, :set_project_type, :report_fraud ]
before_action :set_ship, only: [ :show, :update, :set_project_type, :set_bonus_stardust, :report_fraud ]
before_action :set_submitter_context, only: [ :show, :update ]
before_action :set_body_class, only: [ :index, :show, :update, :logs ]

Expand Down Expand Up @@ -117,6 +117,12 @@ def set_project_type
end
end

def set_bonus_stardust
authorize @ship
@ship.update!(bonus_stardust: params[:bonus_stardust].presence)
redirect_to admin_certification_ship_path(@ship), notice: "Bonus stardust updated."
end

def update
authorize @ship
if internal_sw_dash_reviews_disabled? && @ship.external_certification_id.present?
Expand Down
7 changes: 6 additions & 1 deletion app/models/certification/ship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Table name: certification_ship_reviews
#
# id :bigint not null, primary key
# bonus_stardust :float
# claim_expires_at :datetime
# claimed_at :datetime
# decided_at :datetime
Expand Down Expand Up @@ -144,6 +145,9 @@ def transfer_external_certification_id_to!(other)
allow_blank: true
validates :verdict_video,
content_type: { in: ACCEPTED_VIDEO_TYPES, spoofing_protection: true }
validates :bonus_stardust,
numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100 },
allow_nil: true

scope :for_reviewer, ->(user) {
joins(:project)
Expand Down Expand Up @@ -393,12 +397,13 @@ def decided_on
decided_at || updated_at
end


private

def assign_stardust_earned
total_count = Certification::Ship.decided_today_count(reviewer_id) + 1
multiplier = Certification::Ship.multiplier_for_milestone(total_count)
self.stardust_earned = REVIEW_BOUNTY * multiplier
self.stardust_earned = (REVIEW_BOUNTY * multiplier) + (bonus_stardust || 0)
end

def stamp_claimed_at
Expand Down
2 changes: 2 additions & 0 deletions app/policies/admin/certification/ship_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def next? = user&.can_review?

def set_project_type? = show?

def set_bonus_stardust? = user&.admin?

def report_fraud? = user&.can_review?

class Scope < ApplicationPolicy::Scope
Expand Down
7 changes: 7 additions & 0 deletions app/views/admin/certification/ships/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@
<div class="ship-queue__project-head">
<span class="ship-queue__project-title"><%= ship.project&.title || "Deleted Project" %></span>
<span class="ship-queue__project-id">#<%= ship.id %></span>
<% if ship.bonus_stardust.present? && ship.bonus_stardust > 0 %>
<span class="ship-queue__bonus-tag">✦ +<%= ship.bonus_stardust %></span>
<% end %>
</div>
<div class="ship-queue__project-links">
<% if ship.project.demo_url.present? %>
Expand Down Expand Up @@ -312,6 +315,10 @@
</div>
<div class="ship-queue__project-meta">
<span>#<%= ship.id %></span>
<% if ship.bonus_stardust.present? && ship.bonus_stardust > 0 %>
<span class="ship-queue__dot" aria-hidden="true">·</span>
<span class="ship-queue__bonus-tag">✦ +<%= ship.bonus_stardust %></span>
<% end %>
<span class="ship-queue__dot" aria-hidden="true">·</span>
<span>by <%= owner&.display_name || "—" %></span>
<% if ship.project.project_type.present? %>
Expand Down
27 changes: 27 additions & 0 deletions app/views/admin/certification/ships/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,33 @@
</section>

<aside class="ship-review__sidebar">
<% if policy(@ship).set_bonus_stardust? %>
<div class="ship-review__panel bonus-stardust">
<h2 class="ship-review__panel-title">Bonus Stardust</h2>
<% if @ship.bonus_stardust.present? %>
<p class="bonus-stardust__current">
Currently: <strong>+<%= @ship.bonus_stardust %></strong> bonus stardust
</p>
<% end %>
<%= form_with url: set_bonus_stardust_admin_certification_ship_path(@ship), method: :patch, class: "bonus-stardust__form" do %>
<div class="bonus-stardust__field">
<%= number_field_tag :bonus_stardust, @ship.bonus_stardust,
step: 0.25, min: 0, max: 100, placeholder: "0.0",
autocomplete: "off",
class: "bonus-stardust__input",
id: "bonus-stardust-input" %>
<%= submit_tag "Set Bonus", class: "action-btn action-btn--small action-btn--primary" %>
</div>
<% end %>
<% if @ship.stardust_earned.present? %>
<div class="bonus-stardust__breakdown">
<span class="bonus-stardust__breakdown-label">Total earned:</span>
<span class="bonus-stardust__breakdown-value"><%= @ship.stardust_earned %> stardust</span>
</div>
<% end %>
</div>
<% end %>

<div class="ship-review__panel"
data-controller="certification--ships--fraud-report"
data-certification--ships--fraud-report-ship-id-value="<%= @ship.id %>">
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@
get :monitor, to: "ships/monitor#show"
end
patch :set_project_type, on: :member
patch :set_bonus_stardust, on: :member
post :report_fraud, on: :member
scope module: :ships do
resource :claim, only: [ :create, :destroy ]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddBonusStardustToCertificationShipReviews < ActiveRecord::Migration[8.1]
def change
add_column :certification_ship_reviews, :bonus_stardust, :float
end
end
1 change: 1 addition & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/models/certification/ship_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Table name: certification_ship_reviews
#
# id :bigint not null, primary key
# bonus_stardust :float
# claim_expires_at :datetime
# claimed_at :datetime
# decided_at :datetime
Expand Down