Skip to content

Commit 10fbed2

Browse files
committed
Recalculate collection dates after adding upload pages
1 parent c19ce4a commit 10fbed2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

backend/btrixcloud/colls.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,15 @@ async def update_collection_counts_and_tags(self, collection_id: UUID):
477477
},
478478
)
479479

480+
async def recalculate_org_collection_dates(self, org: Organization):
481+
"""Recalculate earliest and latest dates for collections in org"""
482+
collections, _ = await self.list_collections(
483+
org,
484+
page_size=100_000,
485+
)
486+
for coll in collections:
487+
await self.update_collection_dates(coll.id)
488+
480489
async def update_collection_dates(self, coll_id: UUID):
481490
"""Update collection earliest and latest dates from page timestamps"""
482491
coll = await self.get_collection(coll_id)

backend/btrixcloud/main_bg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def main():
2828
)
2929
return 1
3030

31-
(org_ops, _, _, _, _, page_ops, _, _, _, _, _, user_manager) = init_ops()
31+
(org_ops, _, _, _, _, page_ops, coll_ops, _, _, _, _, user_manager) = init_ops()
3232

3333
if not oid:
3434
print("Org id missing, quitting")
@@ -61,6 +61,7 @@ async def main():
6161
if job_type == BgJobType.READD_ORG_PAGES:
6262
try:
6363
await page_ops.re_add_all_crawl_pages(org, type_filter=type_filter)
64+
await coll_ops.recalculate_org_collection_dates(org)
6465
return 0
6566
# pylint: disable=broad-exception-caught
6667
except Exception:

0 commit comments

Comments
 (0)