Skip to content

Dynamic payouts#27

Open
ObayM wants to merge 4 commits intohackclub:mainfrom
ObayM:dynamic-payouts
Open

Dynamic payouts#27
ObayM wants to merge 4 commits intohackclub:mainfrom
ObayM:dynamic-payouts

Conversation

@ObayM
Copy link
Contributor

@ObayM ObayM commented Feb 13, 2026

Changed the payouts system to a more engaging and rewarding ones where we reward hard & old projects more than the web apps/new stuff :)

image

Comment on lines +238 to +243
const payout = await calc({
userId: user.id,
projectType: cert.projectType,
verdict: verdict.toLowerCase() as 'approved' | 'rejected',
certCreatedAt: cert.createdAt,
customBounty: cert.customBounty,

This comment was marked as outdated.

@Nullskulls Nullskulls requested a review from EricZil February 13, 2026 15:43
@Nullskulls
Copy link
Member

Please provide a more detailed explanation on what was changed. The PR description is not enough.

@Nullskulls
Copy link
Member

It seems that you've decreased hardware payout and increased apps. Who exactly was this approved by? Respectfully none of this has been run by us.

@Nullskulls
Copy link
Member

1.5x for your 1st review of the day is ambiguous. Is this meant as the first review done by a certain shipwright or all shipwrights generally and in both cases there isn't valid reasoning behind that.

</BarChart>
)}
</ResponsiveContainer>
)
Copy link
Member

Choose a reason for hiding this comment

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

Why is half your PR editing indentation?

Copy link
Contributor Author

@ObayM ObayM Feb 13, 2026

Choose a reason for hiding this comment

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

It's just pnpm pretty
@EricZil wanted this in the last 2 PRs :)

Copy link
Member

@Nullskulls Nullskulls left a comment

Choose a reason for hiding this comment

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

I will not be moving forward with review of this PR seeing as how none of this was discussed with any of us.

@ObayM
Copy link
Contributor Author

ObayM commented Feb 13, 2026

Please provide a more detailed explanation on what was changed. The PR description is not enough.

This was disccused with Dhamari, hardware should be decreased as the reviewer doesn't need to install anything to thier system, so it's just reading the files/watching a demo

For apps, you need an emulator to test it which isn't really easy to get :)

Also this increase was offset by a decrease in web applications, which represent approximately 50%.

@ObayM
Copy link
Contributor Author

ObayM commented Feb 13, 2026

1.5x for your 1st review of the day is ambiguous. Is this meant as the first review done by a certain shipwright or all shipwrights generally and in both cases there isn't valid reasoning behind that.

Okay, this was set to motivate shipwrights to do at least 1 review a day, it's just a very small bonus to motivate inactive shipwrights to do one review and if they did one, it's very likely they will continue doing more certs :)

Comment on lines 236 to +243

if (verdict.toLowerCase() === 'approved' || verdict.toLowerCase() === 'rejected') {
const payout = await calc(user.id, cert.projectType, cert.customBounty)
const payout = await calc({
userId: user.id,
projectType: cert.projectType,
verdict: verdict.toLowerCase() as 'approved' | 'rejected',
certCreatedAt: cert.createdAt,
customBounty: cert.customBounty,
Copy link

Choose a reason for hiding this comment

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

Bug: A race condition exists where concurrent review certifications can both receive the same daily bonus multiplier, as the payout is calculated before the review completion is saved to the database.
Severity: MEDIUM

Suggested Fix

Wrap the critical section of the PATCH endpoint, from reading the review count with getDailyMulti() to updating the shipCert record, within a prisma.$transaction(). This will ensure the read and write operations are atomic, preventing other requests from reading stale data.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: sw-dash/src/app/api/admin/ship_certifications/[id]/route.ts#L236-L243

Potential issue: The payout multiplier is calculated by `calc()` before the database
update commits the review's `reviewCompletedAt` timestamp. If two certification requests
are processed concurrently, both calls to `getDailyMulti()` could query the database
before either review is marked as complete. This would cause both requests to
incorrectly receive the same tiered bonus, such as the "first review of the day" 1.5x
multiplier, leading to users earning duplicate rewards. The issue is present for
multiple bonus thresholds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants