Skip to content

Commit

Permalink
add pending actions to cover inquiries to migration
Browse files Browse the repository at this point in the history
  • Loading branch information
guzzijones committed Oct 10, 2023
1 parent 0472e90 commit 605447b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions st2common/bin/migrations/v3.9/st2-migrate-liveaction-executiondb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ from st2common.models.db.execution import ActionExecutionDB
from st2common.constants.action import (
LIVEACTION_COMPLETED_STATES,
LIVEACTION_STATUS_PAUSED,
LIVEACTION_STATUS_PENDING
)

# NOTE: To avoid unnecessary mongoengine object churn when retrieving only object ids (aka to avoid
Expand All @@ -68,21 +69,24 @@ def migrate_executions(start_dt: datetime.datetime, end_dt: datetime.datetime) -
res_count = ActionExecutionDB.objects(
__raw__={
"status": {
"$in": LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED],
"$in": LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED, LIVEACTION_STATUS_PENDING],
},
},
start_timestamp__gte=start_dt,
start_timestamp__lte=end_dt,
).as_pymongo()
for item in res_count:
ActionExecutionDB.objects(__raw__={"_id": item["_id"]}).update(
__raw__={"$set": {"liveaction_id": item["liveaction"]["id"]}}
)
try:
ActionExecutionDB.objects(__raw__={"_id": item["_id"]}).update(
__raw__={"$set": {"liveaction_id": item["liveaction"]["id"]}}
)
except KeyError as e:
pass

ActionExecutionDB.objects(
__raw__={
"status": {
"$in": LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED],
"$in": LIVEACTION_COMPLETED_STATES + [LIVEACTION_STATUS_PAUSED, LIVEACTION_STATUS_PENDING],
},
},
start_timestamp__gte=start_dt,
Expand Down

0 comments on commit 605447b

Please sign in to comment.