Skip to content

[#884] Add write + rate point hooks#903

Merged
realproject7 merged 2 commits intomainfrom
task/884-write-rate-hooks
Apr 21, 2026
Merged

[#884] Add write + rate point hooks#903
realproject7 merged 2 commits intomainfrom
task/884-write-rate-hooks

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • New lib/airdrop/award.ts with awardWritePoints() (50 PL per storyline) and awardRatePoints() (5 PL per rating, max 10/day)
  • Hooked into storyline indexer (src/app/api/index/storyline/route.ts)
  • Hooked into backfill cron (src/app/api/cron/backfill/route.ts) for StorylineCreated events
  • Hooked into ratings endpoint (src/app/api/ratings/route.ts) after successful upsert
  • All hooks are non-blocking (fire-and-forget with .catch(() => {}))
  • Both functions: check campaign window, dedup via metadata.storyline_id, apply streak boost

Files Changed

  • lib/airdrop/award.ts — new award helpers
  • src/app/api/index/storyline/route.ts — write point hook
  • src/app/api/cron/backfill/route.ts — write point hook (backfill path)
  • src/app/api/ratings/route.ts — rate point hook

Test plan

  • Publish a storyline during campaign → verify 50 PL (boosted) in pl_points
  • Publish same storyline again → verify no duplicate points
  • Rate a story → verify 5 PL (boosted) in pl_points
  • Rate 11 stories in one day → verify only 10 get points
  • Verify no points outside campaign window
  • Backfill picks up historical StorylineCreated events within campaign

Fixes #884

🤖 Generated with Claude Code

- New lib/airdrop/award.ts with awardWritePoints (50 PL) and
  awardRatePoints (5 PL, daily cap of 10)
- Hook awardWritePoints into storyline indexer and backfill cron
  (non-blocking, with campaign window + dedup checks)
- Hook awardRatePoints into ratings POST endpoint
  (non-blocking, with daily cap + dedup)
- Both respect campaign window and apply streak boost

Fixes #884

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Apr 21, 2026 1:31am

Request Review

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: REQUEST CHANGES

Summary

The general award-hook shape is reasonable, but the write-points path in the live storyline indexer does not currently enforce the campaign window using the storyline's publish timestamp as the ticket requires.

Findings

  • [high] src/app/api/index/storyline/route.ts calls awardWritePoints() without the storyline's on-chain block_timestamp, so awardWritePoints() falls back to new Date() and awards based on indexing time rather than publication time. That means an old storyline indexed during the campaign can incorrectly receive points, and a storyline published during the campaign but indexed later can incorrectly miss them.
    • File: src/app/api/index/storyline/route.ts:188
    • Suggestion: pass the storyline's actual block timestamp into awardWritePoints() in this path as well, matching the backfill implementation and the issue requirement to gate on block_timestamp.

Decision

Requesting changes because the live storyline-index path does not currently satisfy the campaign-window acceptance criteria for write points.

Use on-chain blockTimestamp instead of Date.now() so campaign window
check is based on publication time, not indexing time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: APPROVE

Summary

The live storyline-index path now passes the on-chain blockTimestamp into awardWritePoints(), so the campaign-window check is based on publication time as required. The write/rate award hooks otherwise remain aligned with the ticket scope.

Findings

  • No blocking findings in the updated patch.

Decision

Approving from a code-review standpoint. The blocker from my previous review is resolved, and I do not see a remaining PR-specific code issue.

@realproject7 realproject7 merged commit e31ccce into main Apr 21, 2026
2 of 4 checks passed
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.

[Airdrop P2] Write + Rate point hooks

2 participants