-
Notifications
You must be signed in to change notification settings - Fork 30
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
nicoll/splits automation #1771
nicoll/splits automation #1771
Conversation
nicollguarnizo
commented
Oct 30, 2024
•
edited
Loading
edited
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
@@ -62,28 +62,10 @@ export default defineType({ | |||
}, | |||
}), | |||
defineField({ | |||
name: 'revenueSplits', |
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.
went ahead and deleted this section
contributor?: SplitInfo | ||
} | ||
|
||
const defineSplits = await step.run( |
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.
define splits based on contributor and moduleType
"instructor": contributors[0].contributor->{ | ||
userId, | ||
name, |
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.
I'm not a huge fan of this and we should probably not hard code a zero-index lookup here and consider multiple instructors immediately.
@@ -82,6 +83,114 @@ export const sanityProductCreated = inngest.createFunction( | |||
}) | |||
}) | |||
|
|||
type SplitInfo = { | |||
type: string |
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.
type here is 'owner' | 'skill' | string
could use a discriminated union so that the userId would only be there if it was type
owner`
if (isOwnerInstructor) { | ||
if (isSelfPaced) { | ||
splits.skill.percent = 0.4 | ||
splits.owner.percent = 0.6 | ||
} else { | ||
splits.skill.percent = 0.15 | ||
splits.owner.percent = 0.85 | ||
} | ||
} else { | ||
if (isSelfPaced) { | ||
splits.skill.percent = 0.5 | ||
splits.owner.percent = 0.2 | ||
splits.contributor = { | ||
type: 'contributor', | ||
percent: 0.3, | ||
userId: instructor?.userId, | ||
} | ||
} else { | ||
splits.skill.percent = 0.15 | ||
splits.owner.percent = 0.15 | ||
splits.contributor = { | ||
type: 'contributor', | ||
percent: 0.7, | ||
userId: instructor?.userId, | ||
} | ||
} | ||
} |
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 is kind of harsh, but I am concerned with it's hard-coding very specific business values and mutating an object through another object. To the extent that I think we might need to rethink the entire data model and implementation of the PR.
We can keep trying like this or write a plan, diagram the flows, etc before implementing
I'd rather have it just manually added to the database. 😬
type SplitInfo = { | ||
type: string | ||
percent: number | ||
userId: string | undefined | null | ||
} | ||
|
||
type Splits = { | ||
skill: SplitInfo | ||
owner: SplitInfo | ||
contributor?: SplitInfo | ||
} |
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.
super important to have types exist in 1 spot only
if (isOwnerInstructor) { | ||
if (isSelfPaced) { | ||
splits.skill.percent = 0.4 | ||
splits.owner.percent = 0.6 | ||
} else { | ||
splits.skill.percent = 0.15 | ||
splits.owner.percent = 0.85 | ||
} | ||
} else { | ||
if (isSelfPaced) { | ||
splits.skill.percent = 0.5 | ||
splits.owner.percent = 0.2 | ||
splits.contributor = { | ||
type: 'contributor', | ||
percent: 0.3, | ||
userId: instructor?.userId, | ||
} | ||
} else { | ||
splits.skill.percent = 0.15 | ||
splits.owner.percent = 0.15 | ||
splits.contributor = { | ||
type: 'contributor', | ||
percent: 0.7, | ||
userId: instructor?.userId, | ||
} | ||
} | ||
} | ||
|
||
return splits | ||
}, | ||
) |
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.
oh, looks like it's all repeated