Share rewards: a question for a visit, an analysis for a new user
A click proves little, so the first visit of a shared link now earns a question (once per user) instead of a natal analysis. A natal analysis is earned by bringing a new user: the share page remembers the link, the Google sign-up sends it, and when that user makes their own chart the sharer gets one, at most three (referrals table, referral_reward). This is off until sign-up opens (REFERRAL_REWARDS, default false). The share button and its small print follow; /v1/me tells what was earned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
-- Sharing pays in two steps: the first visit of a shared link earns a
|
||||
-- question (`share_reward`, see shares.rs), and someone who signs up from a
|
||||
-- shared link and makes their own chart earns the sharer a natal analysis
|
||||
-- (`referral_reward`, at most three per user).
|
||||
ALTER TABLE credit_ledger DROP CONSTRAINT credit_ledger_reason_check;
|
||||
ALTER TABLE credit_ledger ADD CONSTRAINT credit_ledger_reason_check
|
||||
CHECK (reason IN ('monthly_grant', 'analysis', 'chat', 'refund', 'admin_adjust', 'purchase', 'person', 'package',
|
||||
'question', 'share_reward', 'referral_reward'));
|
||||
|
||||
-- Who came through whose shared link (one row per new user).
|
||||
CREATE TABLE referrals (
|
||||
user_id uuid PRIMARY KEY REFERENCES users (id) ON DELETE CASCADE,
|
||||
referrer_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
||||
share_id uuid REFERENCES shares (id) ON DELETE SET NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
-- Set when the new user made their own chart (rewarded or over the limit).
|
||||
rewarded_at timestamptz
|
||||
);
|
||||
CREATE INDEX referrals_referrer_idx ON referrals (referrer_id);
|
||||
Reference in New Issue
Block a user