1- from typing import Any
21from uuid import UUID
32
4- from sqlalchemy import Select , func , exists , select
53from sqlalchemy .ext .asyncio import AsyncSession
6- from sqlalchemy .orm import joinedload
74
85from src .api .endpoints .annotate ._shared .extract import extract_and_format_get_annotation_result
6+ from src .api .endpoints .annotate ._shared .queries import helper
97from src .api .endpoints .annotate .all .get .models .response import GetNextURLForAllAnnotationResponse
108from src .api .endpoints .annotate .anonymous .get .helpers import not_exists_anon_annotation
119from src .api .endpoints .annotate .anonymous .get .response import GetNextURLForAnonymousAnnotationResponse
12- from src .collectors .enums import URLStatus
13- from src .db .helpers .query import not_exists_url
1410from src .db .models .impl .annotation .agency .anon .sqlalchemy import AnnotationAgencyAnon
1511from src .db .models .impl .annotation .location .anon .sqlalchemy import AnnotationLocationAnon
1612from src .db .models .impl .annotation .record_type .anon .sqlalchemy import AnnotationAnonRecordType
1713from src .db .models .impl .annotation .url_type .anon .sqlalchemy import AnnotationAnonURLType
18- from src .db .models .impl .flag .url_suspended .sqlalchemy import FlagURLSuspended
1914from src .db .models .impl .url .core .sqlalchemy import URL
20- from src .db .models .views .unvalidated_url import UnvalidatedURL
21- from src .db .models .views .url_anno_count import URLAnnotationCount
22- from src .db .models .views .url_annotations_flags import URLAnnotationFlagsView
2315from src .db .queries .base .builder import QueryBuilderBase
24- from src .api .endpoints .annotate ._shared .queries import helper
2516
2617
2718class GetNextURLForAnonymousAnnotationQueryBuilder (QueryBuilderBase ):
@@ -40,7 +31,6 @@ async def run(self, session: AsyncSession) -> GetNextURLForAnonymousAnnotationRe
4031 query = (
4132 query
4233 .where (
43- URL .status == URLStatus .OK .value ,
4434 # Must not have been previously annotated by user
4535 not_exists_anon_annotation (
4636 session_id = self .session_id ,
@@ -57,14 +47,6 @@ async def run(self, session: AsyncSession) -> GetNextURLForAnonymousAnnotationRe
5747 not_exists_anon_annotation (
5848 session_id = self .session_id ,
5949 anon_model = AnnotationAgencyAnon
60- ),
61- ~ exists (
62- select (
63- FlagURLSuspended .url_id
64- )
65- .where (
66- FlagURLSuspended .url_id == URL .id ,
67- )
6850 )
6951 )
7052 )
0 commit comments