mirror of
https://github.com/jaypyles/Scraperr.git
synced 2025-12-09 09:15:42 +00:00
feat: add favorites tab in jobs
This commit is contained in:
@@ -24,6 +24,7 @@ from api.backend.job import (
|
||||
query,
|
||||
insert,
|
||||
delete_jobs,
|
||||
update_job,
|
||||
)
|
||||
from api.backend.models import (
|
||||
DownloadJob,
|
||||
@@ -31,6 +32,7 @@ from api.backend.models import (
|
||||
SubmitScrapeJob,
|
||||
DeleteScrapeJobs,
|
||||
RetrieveScrapeJobs,
|
||||
UpdateJobs,
|
||||
)
|
||||
from api.backend.auth.auth_router import auth_router
|
||||
import traceback
|
||||
@@ -67,6 +69,12 @@ def read_favicon():
|
||||
return FileResponse("dist/favicon.ico")
|
||||
|
||||
|
||||
@app.post("/api/update")
|
||||
async def update(update_jobs: UpdateJobs):
|
||||
"""Used to update jobs"""
|
||||
await update_job(update_jobs.ids, update_jobs.field, update_jobs.value)
|
||||
|
||||
|
||||
@app.post("/api/submit-scrape-job")
|
||||
async def submit_scrape_job(job: SubmitScrapeJob, background_tasks: BackgroundTasks):
|
||||
LOG.info(f"Recieved job: {job}")
|
||||
|
||||
@@ -34,13 +34,13 @@ async def query(filter: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
return results
|
||||
|
||||
|
||||
async def update_job(id: str, field: str, value: Any):
|
||||
async def update_job(ids: list[str], field: str, value: Any):
|
||||
collection = get_job_collection()
|
||||
result = await collection.update_one(
|
||||
{"id": id},
|
||||
{"$set": {field: value}},
|
||||
)
|
||||
return result.modified_count
|
||||
for id in ids:
|
||||
_ = await collection.update_one(
|
||||
{"id": id},
|
||||
{"$set": {field: value}},
|
||||
)
|
||||
|
||||
|
||||
async def delete_jobs(jobs: list[str]):
|
||||
|
||||
@@ -48,3 +48,9 @@ class DeleteScrapeJobs(pydantic.BaseModel):
|
||||
|
||||
class GetStatistics(pydantic.BaseModel):
|
||||
user: str
|
||||
|
||||
|
||||
class UpdateJobs(pydantic.BaseModel):
|
||||
ids: list[str]
|
||||
field: str
|
||||
value: Any
|
||||
|
||||
Reference in New Issue
Block a user