diff --git a/backend/btrixcloud/crawls.py b/backend/btrixcloud/crawls.py index 73adad177e..62b7aef326 100644 --- a/backend/btrixcloud/crawls.py +++ b/backend/btrixcloud/crawls.py @@ -723,19 +723,31 @@ async def inc_crawl_exec_time( crawl_id: str, is_qa: bool, exec_time: int, + elapsed_time: int, last_updated_time: datetime, - ) -> bool: + ) -> tuple[int, int]: """increment exec time""" # update both crawl-shared qa exec seconds and per-qa run exec seconds - if is_qa: + + field = "_lut" + + # nop if times are 0 + if elapsed_time <= 0 and exec_time <= 0: + inc_update = {} + + elif is_qa: inc_update = { "qaCrawlExecSeconds": exec_time, "qa.crawlExecSeconds": exec_time, + "qaCrawlElapsedSeconds": exec_time, + "qa.crawlElapsedSeconds": exec_time, } field = "qa._lut" else: - inc_update = {"crawlExecSeconds": exec_time} - field = "_lut" + inc_update = { + "crawlExecSeconds": exec_time, + "crawlElapsedSeconds": elapsed_time, + } res = await self.crawls.find_one_and_update( { @@ -748,7 +760,16 @@ async def inc_crawl_exec_time( "$set": {field: last_updated_time}, }, ) - return res is not None + if not res: + return 0, 0 + + exec_seconds = res.get( + "crawlExecSeconds" if not is_qa else "qaCrawlExecSeconds" + ) + elapsed_seconds = res.get( + "crawlElapsedSeconds" if not is_qa else "qaCrawlElapsedSeconds" + ) + return exec_seconds, elapsed_seconds async def get_crawl_exec_last_update_time( self, crawl_id: str, is_qa: bool diff --git a/backend/btrixcloud/models.py b/backend/btrixcloud/models.py index ec5e78cb87..69aac4d2d7 100644 --- a/backend/btrixcloud/models.py +++ b/backend/btrixcloud/models.py @@ -945,6 +945,7 @@ class CoreCrawlable(BaseModel): state: str crawlExecSeconds: int = 0 + crawlElapsedSeconds: int = 0 image: str | None = None @@ -1036,6 +1037,8 @@ class CrawlOut(BaseMongoModel): crawlExecSeconds: int = 0 qaCrawlExecSeconds: int = 0 + crawlElapsedSeconds: int = 0 + qaCrawlElapsedSeconds: int = 0 # automated crawl fields config: RawCrawlConfig | None = None @@ -1181,6 +1184,7 @@ class QARunOut(BaseModel): state: str crawlExecSeconds: int = 0 + crawlElapsedSeconds: int = 0 stats: CrawlStats = CrawlStats() diff --git a/backend/btrixcloud/operator/crawls.py b/backend/btrixcloud/operator/crawls.py index 3afc76d4c1..4fb2e5ae62 100644 --- a/backend/btrixcloud/operator/crawls.py +++ b/backend/btrixcloud/operator/crawls.py @@ -1419,7 +1419,7 @@ async def increment_pod_exec_time( ) await self.crawl_ops.inc_crawl_exec_time( - crawl.db_crawl_id, crawl.is_qa, 0, now + crawl.db_crawl_id, crawl.is_qa, 0, 0, now ) status.lastUpdatedTime = date_to_str(now) return @@ -1521,12 +1521,17 @@ async def increment_pod_exec_time( exec_time += duration max_duration = max(duration, max_duration) - if exec_time: + if exec_time > 0: await self.org_ops.inc_org_time_stats( crawl.oid, exec_time, True, crawl.is_qa ) - status.crawlExecTime += exec_time - status.elapsedCrawlTime += max_duration + + newExecTime, newElapsedTime = await self.crawl_ops.inc_crawl_exec_time( + crawl.db_crawl_id, crawl.is_qa, exec_time, max_duration, now + ) + + status.crawlExecTime = max(newExecTime, status.crawlExecTime) + status.elapsedCrawlTime = max(newElapsedTime, status.elapsedCrawlTime) logger.debug( "pod_exec_time_total_computed", @@ -1538,9 +1543,6 @@ async def increment_pod_exec_time( ), ) - await self.crawl_ops.inc_crawl_exec_time( - crawl.db_crawl_id, crawl.is_qa, exec_time, now - ) status.lastUpdatedTime = date_to_str(now) def should_mark_waiting(self, state: TYPE_ALL_CRAWL_STATES, started: str) -> bool: diff --git a/backend/btrixcloud/version.py b/backend/btrixcloud/version.py index 26ecab9ee8..b1f607190f 100644 --- a/backend/btrixcloud/version.py +++ b/backend/btrixcloud/version.py @@ -2,6 +2,6 @@ import os -__version__ = "1.25.0" +__version__ = "1.25.1" __commit_hash__ = os.environ.get("GIT_COMMIT_HASH") __branch__ = os.environ.get("GIT_BRANCH_NAME") diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 396a6e2b51..c9bdc2bcaf 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "backend" -version = "1.25.0" +version = "1.25.1" description = "Browsertrix backend" requires-python = ">=3.12" dependencies = [ diff --git a/backend/uv.lock b/backend/uv.lock index e105a1b70a..26a556e51b 100644 --- a/backend/uv.lock +++ b/backend/uv.lock @@ -255,7 +255,7 @@ wheels = [ [[package]] name = "backend" -version = "1.25.0" +version = "1.25.1" source = { virtual = "." } dependencies = [ { name = "aiobotocore" }, diff --git a/chart/Chart.yaml b/chart/Chart.yaml index ccafee16b8..8104c9ba63 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -5,7 +5,7 @@ type: application icon: https://webrecorder.net/assets/icon.png # Browsertrix and Chart Version -version: v1.25.0 +version: v1.25.1 dependencies: - name: btrix-admin-logging diff --git a/chart/values.yaml b/chart/values.yaml index d9a773114a..5abd71e493 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -119,7 +119,7 @@ replica_deletion_delay_days: 0 # API Image # ========================================= -backend_image: "docker.io/webrecorder/browsertrix-backend:1.25.0" +backend_image: "docker.io/webrecorder/browsertrix-backend:1.25.1" backend_pull_policy: "IfNotPresent" backend_password_secret: "PASSWORD!" @@ -194,7 +194,7 @@ stuck_uploads_cron_schedule: "0 * * * *" # Emails Image # ========================================= -emails_image: "docker.io/webrecorder/browsertrix-emails:1.25.0" +emails_image: "docker.io/webrecorder/browsertrix-emails:1.25.1" emails_pull_policy: "IfNotPresent" emails_cpu: "10m" @@ -208,7 +208,7 @@ local_emails_port: 30872 # Nginx Image # ========================================= -frontend_image: "docker.io/webrecorder/browsertrix-frontend:1.25.0" +frontend_image: "docker.io/webrecorder/browsertrix-frontend:1.25.1" frontend_pull_policy: "IfNotPresent" frontend_cpu: "10m" diff --git a/frontend/package.json b/frontend/package.json index 023323e9e4..7b0a27627d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "browsertrix-frontend", - "version": "1.25.0", + "version": "1.25.1", "main": "index.ts", "license": "AGPL-3.0-or-later", "dependencies": { diff --git a/version.txt b/version.txt index ad2191947f..d905a6d1d6 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.25.0 +1.25.1