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

api: task: add projectId to tasks #2268

Merged
merged 8 commits into from
Aug 28, 2024
Merged

api: task: add projectId to tasks #2268

merged 8 commits into from
Aug 28, 2024

Conversation

gioelecerati
Copy link
Member

What does this pull request do? Explain your changes. (required)

  • Add projectId to tasks. The project is either the projectId of the input asset, the output asset or the defaultprojectId is neither is specified or existing

Specific updates (required)

How did you test each of these updates (required)

Does this pull request close any open issues?

Screenshots (optional)

Checklist

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@gioelecerati gioelecerati requested a review from a team as a code owner July 17, 2024 16:17
Copy link

vercel bot commented Jul 17, 2024

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

Name Status Preview Comments Updated (UTC)
livepeer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 4:54pm

Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need clarification on the task APIs behavior

packages/api/src/task/scheduler.ts Outdated Show resolved Hide resolved
packages/api/src/schema/db-schema.yaml Show resolved Hide resolved
Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I think this is overcomplicating things grabbing the userId from several different places and re-fetching it from the DB all the time. I think it could be greatly simplified by not making arguments optional and just passing the user object around. The tasks logic should never execute without a user.

packages/api/src/task/scheduler.ts Outdated Show resolved Hide resolved
packages/api/src/task/scheduler.ts Outdated Show resolved Hide resolved
packages/api/src/task/scheduler.ts Show resolved Hide resolved
packages/api/src/task/scheduler.ts Outdated Show resolved Hide resolved
inputAsset?: Asset,
outputAsset?: Asset,
userId?: string,
requesterId?: string,
) {
const projectId = inputAsset?.projectId || user?.defaultProjectId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this come from the request API key instead? i.e. req.project?.id || user.defaultProjectId (user is never null, should not ?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, but in the clip case the owner is different than the requester - I could pass req.project.id everywhere but there, but I instead removed userId and I am passing the user object, passing the owner during the clip gen, how does it look?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing a bunch of test failure after addressing the comments tho, looking into it

packages/api/src/task/scheduler.ts Outdated Show resolved Hide resolved
packages/api/src/task/scheduler.ts Outdated Show resolved Hide resolved
packages/api/src/task/scheduler.ts Outdated Show resolved Hide resolved
packages/api/src/webhooks/cannon.ts Outdated Show resolved Hide resolved
@gioelecerati gioelecerati merged commit 3794beb into master Aug 28, 2024
8 checks passed
@gioelecerati gioelecerati deleted the gio/task/projectId branch August 28, 2024 17:03
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