-
Notifications
You must be signed in to change notification settings - Fork 333
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
feat: allow 2 custom templates for every user #9518
Conversation
featureFlags { | ||
noTemplateLimit | ||
} | ||
freeCustomRetroTemplatesRemaining |
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 created two flags, freeCustomRetroTemplatesRemaining
and freeCustomPokerTemplatesRemaining
, thinking of our engineering principle that we should repeat the code twice and, on the third time, refactor it into something reusable.
@@ -15,6 +17,14 @@ const AddPokerTemplatePayload = new GraphQLObjectType<any, GQLContext>({ | |||
if (!templateId) return null | |||
return dataLoader.get('meetingTemplates').load(templateId) | |||
} | |||
}, | |||
user: { |
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'll refactor this to the SDL pattern in a follow-up PR. This PR already touches a lot of files, so I didn't want to bloat it further
@@ -53,16 +53,17 @@ const AddNewPokerTemplate = (props: Props) => { | |||
id | |||
user { | |||
id | |||
featureFlags { | |||
noTemplateLimit |
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.
Now that we've removed the template limit, we should remove this flag altogether. I've created an issue: #9523
packages/server/postgres/migrations/1709733510511_addFreeCustomTemplatesRemaining.ts
Outdated
Show resolved
Hide resolved
import {decrementFreeRetroTemplatesRemainingQuery} from './generated/decrementFreeCustomRetroTemplatesRemainingQuery' | ||
import {decrementFreePokerTemplatesRemainingQuery} from './generated/decrementFreeCustomPokerTemplatesRemainingQuery' | ||
|
||
const decrementFreeTemplatesRemaining = async (userId: string, templateType: 'retro' | 'poker') => { |
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.
-1 pg-typed is deprecated. can we use kysely instead here?
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.
@nickoferrall thoughts on changing this to kysely?
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.
Ah I've updated the migration to kysely, but not the query. I can do this too
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.
Updated!
Please fix the PR title as it will appear in the changelog |
@Dschoordsch it passes the PR title check. What would you like me to change it to? |
Yes, it passes the check, but if you read
would you know what it means? How about "Allow 2 custom templates for every user"? |
? 'freeCustomRetroTemplatesRemaining' | ||
: 'freeCustomPokerTemplatesRemaining' | ||
|
||
const userBeforeUpdate = await pg |
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.
-1 this is slightly worse than the SQL you had because if this function gets called twice then we risk the first query being a stale read. If there's ever a way to do something in a single SQL command, that should be the goal!
See Playground Link
const person = await db
.updateTable('User')
.set((eb) => ({[field]: eb(field, '-', '1')} ))
.where('id', '=', userId)
.where(field, '>', 0)
.executeTakeFirst()
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.
Makes sense, thanks! Updated
Fix #9473
Demo: https://www.loom.com/share/122c8e9e55db443cb52908a1a6957c07
To test