hicommonwealth / commonwealth

A platform for decentralized communities
https://commonwealth.im
GNU General Public License v3.0
68 stars 44 forks source link

🟩 UserReferrals #9834

Open Rotorsoft opened 1 week ago

Rotorsoft commented 1 week ago

Description

Project user referrals in model, to feed UI (queries)

Stakeholders

Product Engineering
@Jane @John

Model

https://miro.com/app/board/uXjVNZ8oB3U=/?moveToWidget=3458764605012942618&cot=14

Engineering Requirements

  1. Events
    • @dillchen @timolegros what do we have in scope in terms of events we can actually project here?
  2. Schemas
    • referrer user id (PK)
    • referee user id (PK)
    • event_name (PK)
    • created_at (PK)
    • referral_link (in case a user updates the link)
    • other metrics (fees, bonus) - TBD - are we projecting onchain events?
    • Accumulated earnings can be projected in a running total col, a second projection with user level cardinality, or aggregated on the fly in queries - TBD
  3. Business Rules
    • Flat log of events linked to referrals with timestamps
  4. Persistence
    • Sequelize model
  5. Response
    • N/A

Unit Testing

Additional Context

timolegros commented 4 days ago

what do we have in scope in terms of events we can actually project here?

I linked the notion doc in the bucket ticket which shows the possible events we can project.

Rotorsoft commented 4 days ago

We can proceed by keeping the event_name column generic for now. However, if other projected metrics depend on the specific characteristics of each event, we may need to define more detailed requirements. Alternatively, we could explore building a generic mapping system to associate metrics such as fees or other event-specific attributes with the relevant events.