Skip to content

Commit 8229199

Browse files
committed
Update draft
1 parent 2611109 commit 8229199

File tree

48 files changed

+827
-31
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+827
-31
lines changed

ENV.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ Note that some tasks/subtasks are themselves enabled by other tasks.
7070
| `DELETE_STALE_SCREENSHOTS_TASK_FLAG` | Deletes stale screenshots for URLs already validated. |
7171
| `TASK_CLEANUP_TASK_FLAG` | Cleans up tasks that are no longer needed. |
7272
| `REFRESH_MATERIALIZED_VIEWS_TASK_FLAG` | Refreshes materialized views. |
73+
| `DS_APP_SYNC_AGENCY_ADD_FLAG` | Adds new agencies to the Data Sources App|
74+
| `DS_APP_SYNC_AGENCY_UPDATE_FLAG` | Updates existing agencies in the Data Sources App|
75+
| `DS_APP_SYNC_AGENCY_DELETE_FLAG` | Deletes agencies in the Data Sources App|
76+
| `DS_APP_SYNC_DATA_SOURCE_ADD_FLAG` | Adds new data sources to the Data Sources App|
77+
| `DS_APP_SYNC_DATA_SOURCE_UPDATE_FLAG` | Updates existing data sources in the Data Sources App|
78+
| `DS_APP_SYNC_DATA_SOURCE_DELETE_FLAG` | Deletes data sources in the Data Sources App|
79+
| `DS_APP_SYNC_META_URL_ADD_FLAG` | Adds new meta URLs to the Data Sources App|
80+
| `DS_APP_SYNC_META_URL_UPDATE_FLAG` | Updates existing meta URLs in the Data Sources App|
81+
| `DS_APP_SYNC_META_URL_DELETE_FLAG` | Deletes meta URLs in the Data Sources App|
7382

7483
### URL Task Flags
7584

@@ -81,7 +90,6 @@ URL Task Flags are collectively controlled by the `RUN_URL_TASKS_TASK_FLAG` flag
8190
| `URL_HTML_TASK_FLAG` | URL HTML scraping task. |
8291
| `URL_RECORD_TYPE_TASK_FLAG` | Automatically assigns Record Types to URLs. |
8392
| `URL_AGENCY_IDENTIFICATION_TASK_FLAG` | Automatically assigns and suggests Agencies for URLs. |
84-
| `URL_SUBMIT_APPROVED_TASK_FLAG` | Submits approved URLs to the Data Sources App. |
8593
| `URL_MISC_METADATA_TASK_FLAG` | Adds misc metadata to URLs. |
8694
| `URL_AUTO_RELEVANCE_TASK_FLAG` | Automatically assigns Relevances to URLs. |
8795
| `URL_PROBE_TASK_FLAG` | Probes URLs for web metadata. |
@@ -90,7 +98,6 @@ URL Task Flags are collectively controlled by the `RUN_URL_TASKS_TASK_FLAG` flag
9098
| `URL_AUTO_VALIDATE_TASK_FLAG` | Automatically validates URLs. |
9199
| `URL_AUTO_NAME_TASK_FLAG` | Automatically names URLs. |
92100
| `URL_SUSPEND_TASK_FLAG` | Suspends URLs meeting suspension criteria. |
93-
| `URL_SUBMIT_META_URLS_TASK_FLAG` | Submits meta URLs to the Data Sources App. |
94101

95102
### Agency ID Subtasks
96103

alembic/versions/2025_10_28_1539-a57c3b5b6e93_add_sync_log_table.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from alembic import op
1111
import sqlalchemy as sa
1212

13-
from src.util.alembic_helpers import created_at_column
13+
from src.util.alembic_helpers import created_at_column, updated_at_column, create_updated_at_trigger
1414

1515
# revision identifiers, used by Alembic.
1616
revision: str = 'a57c3b5b6e93'
@@ -90,6 +90,9 @@ def _add_link_table_modification_triggers():
9090
)
9191

9292

93+
94+
95+
9396
def upgrade() -> None:
9497
_create_sync_log()
9598
_create_ds_agency_link()
@@ -102,6 +105,16 @@ def upgrade() -> None:
102105
_add_flag_deletion_tables()
103106
_add_last_synced_at_columns()
104107
_add_link_table_modification_triggers()
108+
_add_updated_at_to_optional_data_source_metadata_table()
109+
110+
def _add_updated_at_to_optional_data_source_metadata_table():
111+
op.add_column(
112+
"url_optional_data_source_metadata",
113+
updated_at_column()
114+
)
115+
create_updated_at_trigger(
116+
"url_optional_data_source_metadata"
117+
)
105118

106119
def _add_last_synced_at_columns():
107120
op.add_column(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from sqlalchemy.ext.asyncio import AsyncSession
2+
3+
from src.db.queries.base.builder import QueryBuilderBase
4+
from src.external.pdap.impl.sync.shared.models.mapping import DSSyncIDMapping
5+
6+
7+
class DSAppSyncAgenciesAddInsertLinksQueryBuilder(QueryBuilderBase):
8+
9+
def __init__(
10+
self,
11+
mappings: list[DSSyncIDMapping]
12+
):
13+
super().__init__()
14+
self._mappings = mappings
15+
16+
async def run(self, session: AsyncSession) -> None:
17+
raise NotImplementedError
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
11
"""
22
Agencies to be added to the DS database must not have a
33
ds app link entry
4-
"""
4+
"""
5+
from sqlalchemy import Column, select, exists, CTE
6+
7+
from src.db.models.impl.agency.ds_link.sqlalchemy import DSAppLinkAgency
8+
from src.db.models.impl.agency.sqlalchemy import Agency
9+
10+
11+
class DSAppLinkSyncAgencyAddPrerequisitesCTEContainer:
12+
13+
def __init__(self):
14+
self._cte = (
15+
select(
16+
Agency.id
17+
)
18+
.where(
19+
~exists(
20+
select(DSAppLinkAgency.agency_id)
21+
.where(DSAppLinkAgency.agency_id == Agency.id)
22+
)
23+
).cte()
24+
)
25+
26+
@property
27+
def agency_id(self) -> Column[int]:
28+
return self._cte.columns.id
29+
30+
@property
31+
def cte(self) -> CTE:
32+
return self._cte
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from sqlalchemy.ext.asyncio import AsyncSession
2+
3+
from src.db.queries.base.builder import QueryBuilderBase
4+
from src.external.pdap.impl.sync.agencies.add.request import AddAgenciesOuterRequest
5+
6+
7+
class DSAppSyncAgenciesAddGetQueryBuilder(QueryBuilderBase):
8+
9+
async def run(self, session: AsyncSession) -> AddAgenciesOuterRequest:
10+
raise NotImplementedError
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from sqlalchemy.ext.asyncio import AsyncSession
2+
3+
from src.db.queries.base.builder import QueryBuilderBase
4+
5+
6+
class DSAppSyncAgenciesAddPrerequisitesQueryBuilder(QueryBuilderBase):
7+
8+
async def run(self, session: AsyncSession) -> bool:
9+
raise NotImplementedError
Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
11
"""
22
Agencies to be deleted from the DS database must be flagged for deletion
3-
"""
3+
"""
4+
from sqlalchemy import select, Column, CTE
5+
6+
from src.db.models.impl.agency.ds_link.sqlalchemy import DSAppLinkAgency
7+
from src.db.models.impl.flag.ds_delete.agency import FlagDSDeleteAgency
8+
9+
10+
class DSAppLinkSyncAgencyDeletePrerequisitesCTEContainer:
11+
12+
def __init__(self):
13+
self._cte = (
14+
select(
15+
DSAppLinkAgency.ds_agency_id
16+
)
17+
.join(
18+
FlagDSDeleteAgency,
19+
FlagDSDeleteAgency.ds_agency_id == DSAppLinkAgency.ds_agency_id
20+
).cte()
21+
)
22+
23+
@property
24+
def ds_agency_id(self) -> Column[int]:
25+
return self._cte.columns.ds_agency_id
26+
27+
@property
28+
def cte(self) -> CTE:
29+
return self._cte
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from sqlalchemy.ext.asyncio import AsyncSession
2+
3+
from src.db.queries.base.builder import QueryBuilderBase
4+
5+
6+
class DSAppSyncAgenciesDeleteRemoveFlagsQueryBuilder(QueryBuilderBase):
7+
8+
def __init__(
9+
self,
10+
ds_agency_ids: list[int]
11+
):
12+
super().__init__()
13+
self._ds_agency_ids = ds_agency_ids
14+
15+
async def run(self, session: AsyncSession) -> None:
16+
raise NotImplementedError
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from sqlalchemy.ext.asyncio import AsyncSession
2+
3+
from src.db.queries.base.builder import QueryBuilderBase
4+
5+
6+
class DSAppSyncAgenciesDeleteRemoveLinksQueryBuilder(QueryBuilderBase):
7+
8+
def __init__(
9+
self,
10+
ds_agency_ids: list[int]
11+
):
12+
super().__init__()
13+
self._ds_agency_ids = ds_agency_ids
14+
15+
async def run(self, session: AsyncSession) -> None:
16+
raise NotImplementedError
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from sqlalchemy.ext.asyncio import AsyncSession
2+
3+
from src.db.queries.base.builder import QueryBuilderBase
4+
5+
6+
class DSAppSyncAgenciesDeleteGetQueryBuilder(QueryBuilderBase):
7+
8+
async def run(self, session: AsyncSession) -> list[int]:
9+
"""Get DS App links to delete."""
10+
raise NotImplementedError

0 commit comments

Comments
 (0)