-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add move action #340
Add move action #340
Conversation
config: z.object({ | ||
stage: z.string().describe("Destination stage"), | ||
}), | ||
description: "Move a pub to a different stage", |
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.
Adding some indication its the id here would be nice
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.
Good call. I think I'll skip updating the description for now because we'll need to provide a custom dropdown that populates with the community's stages. But I can add a comment.
core/actions/move/run.ts
Outdated
pubId: pub.id as PubsId, | ||
stageId: config.stage as StagesId, | ||
}) | ||
.execute(); |
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 think this is movePub
query is a good candidate for being extracted to a kysely helpers module (or just an existing lib/server module) since there are so many ways to do it, and one of them (updating rather than insert+delete) breaks our event listener.
Separately, do you know how doing these queries in a transaction compares to doing them in a CTE? Is it still a single request/response if you use a transaction?
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 doubt it treats two operations any differently other than rolling them back in the event of an error, so its probably opening two "connections". I'm actually not sure if a CTE would be rolled back within a transaction. And furthermore I'm not sure if doing a destructive operation within a CTE is a good pattern or not just to save a round trip. It was my understanding that CTEs are mostly used for generating read-only views (e.g. in the case of a recursive query) used by the outer/primary portion of a query.
I'll pull the query out into a kysely helper.
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.
Just added the cte change per our slack convo! Feel free to extract it but we can also do that later.
I also tested it out and it works well! I do think we should change the stage selection from a string to a list of stages by name, but there's a lot of ways we could do that so I can see why you'd want to wait on that. just saw your comment lol
This PR adds a simple
move
action that moves pubs between stages.The moves are immedately reflected (when run manually) in the UI. This was accomplished by adding a
revalidateTag
call in the actions framework code.This PR also adds a fourth
stageId
parameter to the action run functions. This will allow actions to do work in the context of their stage. In this case, thestageId
parameter is used to remove the pub from the stage where the action was run.Issue(s) Resolved
Resolves #339
Test Plan
move
action to a stage. Configure the action instance with the stage id of the stage you plan to move pubs into.