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
5 changes: 2 additions & 3 deletions app/controllers/admin/ship_certifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def index
end

# Calculate payment stats for reviewers including pending requests
# Only count decisions made since the payout system was implemented (September 3, 2025)
feature_launch_date = Date.new(2025, 9, 3).beginning_of_day
# Only count decisions made since the payout system was implemented
feature_launch_date = ShipReviewerPayoutService::FEATURE_LAUNCH_DATE

@payment_stats = User.joins("INNER JOIN ship_certifications ON users.id = ship_certifications.reviewer_id")
.joins("INNER JOIN projects ON ship_certifications.project_id = projects.id")
Expand Down Expand Up @@ -235,7 +235,6 @@ def reviewer_leaderboard(since: nil)
scope = ShipCertification
.joins(:reviewer, :project)
.where.not(reviewer_id: nil)
.where("ship_certifications.updated_at > ship_certifications.created_at")
.where.not(judgement: :pending)
.where(projects: { is_deleted: false })
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the condition .where("ship_certifications.updated_at > ship_certifications.created_at") from the reviewer leaderboard query changes the behavior significantly. This condition was filtering for decisions that were actually made (updated after creation), and its removal may include certifications that were never reviewed. Consider whether this behavioral change is intentional, and if so, ensure it aligns with the business logic for the leaderboard.

Suggested change
.where(projects: { is_deleted: false })
.where(projects: { is_deleted: false })
.where("ship_certifications.updated_at > ship_certifications.created_at")

Copilot uses AI. Check for mistakes.
.group("users.id", "users.display_name", "users.email")
Expand Down
6 changes: 3 additions & 3 deletions app/services/ship_reviewer_payout_service.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class ShipReviewerPayoutService
# Feature launch date - when ship reviewer payouts started
FEATURE_LAUNCH_DATE = Date.new(2025, 9, 3).beginning_of_day.freeze
def self.can_request_payout?(reviewer)
unpaid_decisions = count_unpaid_decisions(reviewer)
unpaid_decisions >= 2 && !has_pending_request?(reviewer)
Expand Down Expand Up @@ -27,16 +29,14 @@ def self.request_payout(reviewer)

def self.count_unpaid_decisions(reviewer)
# Count decisions made by this reviewer since the payout system was implemented
# Only count decisions made after September 3, 2025 (when this feature went live)
feature_launch_date = Date.new(2025, 9, 3).beginning_of_day

total_decisions = ShipCertification
.unscoped
.joins(:project)
.where(reviewer: reviewer)
.where.not(judgement: :pending)
.where("ship_certifications.updated_at > ship_certifications.created_at")
.where("ship_certifications.updated_at >= ?", feature_launch_date)
.where("ship_certifications.updated_at >= ?", FEATURE_LAUNCH_DATE)
.where(projects: { is_deleted: false })
.count

Expand Down