Skip to content

Commit 00be05a

Browse files
committed
rename pausing -> shouldPause, lastCrawlPausing -> lastCrawlShouldPause, except actual derived 'pausing' state in frontend
ensure resources are available for paused state
1 parent 38d3e54 commit 00be05a

File tree

9 files changed

+20
-19
lines changed

9 files changed

+20
-19
lines changed

backend/btrixcloud/basecrawls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
User,
2525
StorageRef,
2626
RUNNING_AND_WAITING_STATES,
27-
SUCCESSFUL_STATES,
27+
SUCCESSFUL_AND_PAUSED_STATES,
2828
QARun,
2929
UpdatedResponse,
3030
DeletedResponseQuota,
@@ -448,7 +448,7 @@ async def _resolve_crawl_refs(
448448

449449
if (
450450
files
451-
and crawl.state in SUCCESSFUL_STATES
451+
and crawl.state in SUCCESSFUL_AND_PAUSED_STATES
452452
and isinstance(crawl, CrawlOutWithResources)
453453
):
454454
crawl.resources = await self._files_to_resources(files, org, crawl.id)

backend/btrixcloud/crawlconfigs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ async def _add_running_curr_crawl_stats(self, crawlconfig: CrawlConfigOut):
771771
crawlconfig.lastCrawlState = crawl.state
772772
crawlconfig.lastCrawlSize = crawl.stats.size if crawl.stats else 0
773773
crawlconfig.lastCrawlStopping = crawl.stopping
774-
crawlconfig.lastCrawlPausing = crawl.pausing
774+
crawlconfig.lastCrawlShouldPause = crawl.shouldPause
775775
crawlconfig.lastCrawlPausedAt = crawl.pausedAt
776776
crawlconfig.lastCrawlPausedExpiry = None
777777
if crawl.pausedAt:

backend/btrixcloud/crawls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ async def pause_crawl(
792792
if result.get("success"):
793793
await self.crawls.find_one_and_update(
794794
{"_id": crawl_id, "type": "crawl", "oid": org.id},
795-
{"$set": {"pausing": pause, "pausedAt": paused_at}},
795+
{"$set": {"shouldPause": pause, "pausedAt": paused_at}},
796796
)
797797

798798
return {"success": True}

backend/btrixcloud/models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ class UserOrgInfoOut(BaseModel):
244244
"stopped_org_readonly",
245245
]
246246
SUCCESSFUL_STATES = get_args(TYPE_SUCCESSFUL_STATES)
247+
SUCCESSFUL_AND_PAUSED_STATES = ["paused", *SUCCESSFUL_STATES]
247248

248249
TYPE_RUNNING_AND_WAITING_STATES = Literal[TYPE_WAITING_STATES, TYPE_RUNNING_STATES]
249250
RUNNING_AND_WAITING_STATES = [*WAITING_STATES, *RUNNING_STATES]
@@ -481,7 +482,7 @@ class CrawlConfigOut(CrawlConfigCore, CrawlConfigAdditional):
481482
id: UUID
482483

483484
lastCrawlStopping: Optional[bool] = False
484-
lastCrawlPausing: Optional[bool] = False
485+
lastCrawlShouldPause: Optional[bool] = False
485486
lastCrawlPausedAt: Optional[datetime] = None
486487
lastCrawlPausedExpiry: Optional[datetime] = None
487488
profileName: Optional[str] = None
@@ -869,7 +870,7 @@ class CrawlOut(BaseMongoModel):
869870
seedCount: Optional[int] = None
870871
profileName: Optional[str] = None
871872
stopping: Optional[bool] = False
872-
pausing: Optional[bool] = False
873+
shouldPause: Optional[bool] = False
873874
pausedAt: Optional[datetime] = None
874875
manual: bool = False
875876
cid_rev: Optional[int] = None
@@ -1025,7 +1026,7 @@ class Crawl(BaseCrawl, CrawlConfigCore):
10251026
manual: bool = False
10261027

10271028
stopping: Optional[bool] = False
1028-
pausing: Optional[bool] = False
1029+
shouldPause: Optional[bool] = False
10291030

10301031
qaCrawlExecSeconds: int = 0
10311032

frontend/src/features/archived-items/crawl-status.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class CrawlStatus extends TailwindElement {
2626
stopping = false;
2727

2828
@property({ type: Boolean })
29-
pausing = false;
29+
shouldPause = false;
3030

3131
@property({ type: Boolean })
3232
hoist = false;
@@ -132,7 +132,7 @@ export class CrawlStatus extends TailwindElement {
132132
label = msg("Pausing");
133133
break;
134134

135-
case "unpausing":
135+
case "resuming":
136136
icon = html`<sl-icon
137137
name="play-circle"
138138
class="animatePulse"
@@ -306,11 +306,11 @@ export class CrawlStatus extends TailwindElement {
306306
if (this.stopping && this.state === "running") {
307307
return "stopping";
308308
}
309-
if (this.pausing && this.state === "running") {
309+
if (this.shouldPause && this.state === "running") {
310310
return "pausing";
311311
}
312-
if (!this.pausing && this.state === "paused") {
313-
return "unpausing";
312+
if (!this.shouldPause && this.state === "paused") {
313+
return "resuming";
314314
}
315315
return this.state;
316316
}

frontend/src/features/crawl-workflows/live-workflow-status.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class LiveWorkflowStatus extends BtrixElement {
107107
class="block"
108108
state=${lastCrawlState}
109109
?stopping=${workflow.lastCrawlStopping}
110-
?pausing=${workflow.lastCrawlPausing}
110+
?shouldPause=${workflow.lastCrawlShouldPause}
111111
></btrix-crawl-status>
112112
`;
113113
});

frontend/src/features/crawl-workflows/workflow-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export class WorkflowListItem extends BtrixElement {
250250
<btrix-crawl-status
251251
state=${workflow.lastCrawlState || msg("No Crawls Yet")}
252252
?stopping=${workflow.lastCrawlStopping}
253-
?pausing=${workflow.lastCrawlPausing}
253+
?shouldPause=${workflow.lastCrawlShouldPause}
254254
></btrix-crawl-status>
255255
`,
256256
)}

frontend/src/pages/org/workflow-detail.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,10 @@ export class WorkflowDetail extends BtrixElement {
569569
this.isCancelingOrStoppingCrawl ||
570570
this.workflow.lastCrawlStopping;
571571
// disable pause/resume button if desired state is already in the process of being set.
572-
// if crawl is running, and already pausing, don't allow clicking Pausing
573-
// if crawl not running, and already unpausing (lastCrawlPausing is false), don't allow clicking Resume
572+
// if crawl is running, and pause requested (shouldPause is true), don't allow clicking Pausing
573+
// if crawl not running, and resume requested (shouldPause is false), don't allow clicking Resume
574574
const disablePauseResume =
575-
this.workflow.lastCrawlPausing ===
575+
this.workflow.lastCrawlShouldPause ===
576576
(this.workflow.lastCrawlState === "running");
577577

578578
return html`
@@ -738,7 +738,7 @@ export class WorkflowDetail extends BtrixElement {
738738
<btrix-crawl-status
739739
state=${workflow.lastCrawlState || msg("No Crawls Yet")}
740740
?stopping=${workflow.lastCrawlStopping}
741-
?pausing=${workflow.lastCrawlPausing}
741+
?shouldPause=${workflow.lastCrawlShouldPause}
742742
></btrix-crawl-status>
743743
`,
744744
)}

frontend/src/types/crawler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export type Workflow = CrawlConfig & {
9292
lastCrawlSize: number | null;
9393
lastStartedByName: string | null;
9494
lastCrawlStopping: boolean | null;
95-
lastCrawlPausing: boolean | null;
95+
lastCrawlShouldPause: boolean | null;
9696
lastRun: string;
9797
totalSize: string | null;
9898
inactive: boolean;

0 commit comments

Comments
 (0)