-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new referral scheme #1255
new referral scheme #1255
Conversation
if (!parent.total) { | ||
return 0 | ||
} | ||
return parent.total |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was throwing errors in development.
const referrerPattern = new URLPattern({ pathname: ':pathname(*)/r/:referrer([\\w_]+)' }) | ||
const itemPattern = new URLPattern({ pathname: '/items/:id(\\d+)' }) | ||
const profilePattern = new URLPattern({ pathname: '/:name([\\w_]+){/:type(\\w+)}?' }) | ||
const territoryPattern = new URLPattern({ pathname: '/~:name([\\w_]+){/*}?' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are waayyyyyyyyyy better than using regex for urls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhh, interesting!
I wish we could use this in the browser, too, but it's not supported by every major browser yet according to MDN:
It's also not implemented in node yet, see nodejs/node#40844.
So cool that next/server
has this implemented!
@ekzyis I marked this ready for review because I want to deploy this before implementing referral rewards so that I can have a real data set to test rewards on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Tested interaction between referrerMiddleware
and oneDayReferral
and did not find any issue.
prisma/migrations/20240706000412_one_day_referrals/migration.sql
Outdated
Show resolved
Hide resolved
const referrerPattern = new URLPattern({ pathname: ':pathname(*)/r/:referrer([\\w_]+)' }) | ||
const itemPattern = new URLPattern({ pathname: '/items/:id(\\d+)' }) | ||
const profilePattern = new URLPattern({ pathname: '/:name([\\w_]+){/:type(\\w+)}?' }) | ||
const territoryPattern = new URLPattern({ pathname: '/~:name([\\w_]+){/*}?' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhh, interesting!
I wish we could use this in the browser, too, but it's not supported by every major browser yet according to MDN:
It's also not implemented in node yet, see nodejs/node#40844.
So cool that next/server
has this implemented!
Great review! I incorporated all your feedback. |
So far this captures the relevant referral data in
middleware.js
, storing it in cookies (for a future login), and passing it in the request headers (for logged in stackers) for storage in the db.how this is going to work
/r/<referrer name>
at the end or invite linkscommentId
attributes a referral to the comment's OPsn_referrer
is set by either explicit or implicit referrals for 24 hoursOneDayReferral
tablereferee
, the most frequentreferrer
of thereferee
(ie contributed the most rows to theOneDayReferral
table for thereferee
) is crowned the "one day referrer" of thereferee
referee
gets 50% of thereferee
's referral rewards, and thereferee
's original referrer (ieusers.referrerId
) get the other 50%todos
OneDayReferrral
table andusers.referrerId
to dole out daily referral rewards