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

(feat/extract) Move extract to a queue system #1044

Merged
merged 12 commits into from
Jan 7, 2025
Merged

Conversation

nickscamara
Copy link
Member

No description provided.

Copy link

sentry-io bot commented Jan 6, 2025

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: apps/api/src/lib/extract/extraction-service.ts

Function Unhandled Issue
performExtraction TypeError: Cannot convert undefined or null to object POST /v1/ex...
Event Count: 2 Affected Users: 0
📄 File: apps/api/src/services/queue-worker.ts (Click to Expand)
Function Unhandled Issue
processJobInternal Error: Missing lock for job dd2d5d28-1767-42b1-8b9f-4be44744ae7d. moveToFinished ...
Event Count: 1 Affected Users: 0
---

Did you find this useful? React with a 👍 or 👎

@nickscamara
Copy link
Member Author

This uses a different queue but we can merge it to be on 1 queue only if preferred @mogery

@nickscamara nickscamara requested a review from mogery January 6, 2025 15:14
@nickscamara nickscamara changed the title (nsc/feat-extract) Move extract to a queue system (feat-extract) Move extract to a queue system Jan 6, 2025
@nickscamara nickscamara changed the title (feat-extract) Move extract to a queue system (feat/extract) Move extract to a queue system Jan 6, 2025
@nickscamara
Copy link
Member Author

  • Let beta users know that we are moving it to a queue system

Copy link
Member

@mogery mogery left a comment

Choose a reason for hiding this comment

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

Rest is good. Though I think right now while it's in progress it will just return Job not found, which is suboptimal.

Comment on lines 14 to 18
const rateLimiter = scrapeStatusRateLimiter;
const incomingIP = (req.headers["x-forwarded-for"] ||
req.socket.remoteAddress) as string;
const iptoken = incomingIP;
await rateLimiter.consume(iptoken);
Copy link
Member

Choose a reason for hiding this comment

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

Why is this here? This is handled by the authMiddleware.

req: RequestWithAuth<{ jobId: string }, any, any>,
res: Response,
) {
try {
Copy link
Member

Choose a reason for hiding this comment

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

You must not wrap v1 endpoint controllers in a try-catch. Error handling is done on the Express middleware level.

Comment on lines 20 to 34
const job = await supabaseGetJobByIdOnlyData(req.params.jobId);
if (!job || job.team_id !== req.auth.team_id) {
return res.status(403).json({
success: false,
error: "You are not allowed to access this resource.",
});
}

const jobData = await supabaseGetJobsById([req.params.jobId]);
if (!jobData || jobData.length === 0) {
return res.status(404).json({
success: false,
error: "Job not found",
});
}
Copy link
Member

Choose a reason for hiding this comment

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

Why request the DB twice?

Copy link
Member

@mogery mogery left a comment

Choose a reason for hiding this comment

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

Meant to RC not approve

@nickscamara
Copy link
Member Author

Wrong branch, will fix it.

Copy link
Member

@mogery mogery left a comment

Choose a reason for hiding this comment

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

good!

apps/api/src/lib/extract/extraction-service.ts Outdated Show resolved Hide resolved
Copy link
Member

@mogery mogery left a comment

Choose a reason for hiding this comment

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

nice

@nickscamara nickscamara merged commit f82a742 into main Jan 7, 2025
1 check failed
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