Skip to content
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

Closed
wants to merge 5 commits into from
Closed

Conversation

nicollguarnizo
Copy link
Contributor

@nicollguarnizo nicollguarnizo commented Oct 30, 2024

splits

Copy link

vercel bot commented Oct 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
badass-turbo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2024 9:12pm
epic-react-v1 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2024 9:12pm
epic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2024 9:12pm
total-typescript-turbo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2024 9:12pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
testing-javascript ⬜️ Ignored (Inspect) Visit Preview Oct 30, 2024 9:12pm

@@ -62,28 +62,10 @@ export default defineType({
},
}),
defineField({
name: 'revenueSplits',
Copy link
Contributor Author

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(
Copy link
Contributor Author

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

Comment on lines +36 to +38
"instructor": contributors[0].contributor->{
userId,
name,
Copy link
Contributor

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
Copy link
Contributor

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`

Comment on lines +118 to +144
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,
}
}
}
Copy link
Contributor

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. 😬

Comment on lines +311 to +321
type SplitInfo = {
type: string
percent: number
userId: string | undefined | null
}

type Splits = {
skill: SplitInfo
owner: SplitInfo
contributor?: SplitInfo
}
Copy link
Contributor

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

Comment on lines +344 to +374
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
},
)
Copy link
Contributor

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

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.

2 participants