Skip to content

Commit

Permalink
23627 add meta data track the stages date (#3019)
Browse files Browse the repository at this point in the history
* 23627 add meta data track the stages date

* fix lint issue

* fix the initial value issue

* update date format

* update stage_date moment

* update stage date moment

* fix sonarcloud issue --wip

* update datetime formate

* fix test issue
  • Loading branch information
kzdev420 authored Oct 4, 2024
1 parent afa6492 commit 91f3451
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions jobs/involuntary-dissolutions/involuntary_dissolutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def stage_1_process(app: Flask): # pylint: disable=redefined-outer-name,too-man

batch_processing.meta_data = {
'overdueARs': ar_overdue,
'overdueTransition': transition_overdue
'overdueTransition': transition_overdue,
'stage_1_date': datetime.utcnow().isoformat()
}
batch_processing.save()
app.logger.debug(f'New batch processing has been created with ID: {batch_processing.id}')
Expand Down Expand Up @@ -266,6 +267,9 @@ def stage_2_process(app: Flask):
batch_processing.step = BatchProcessing.BatchProcessingStep.WARNING_LEVEL_2
batch_processing.trigger_date = datetime.utcnow() + stage_2_delay
app.logger.debug(f'Changed Batch Processing with id: {batch_processing.id} step to level 2.')
if batch_processing.meta_data is None:
batch_processing.meta_data = {}
batch_processing.meta_data = {**batch_processing.meta_data, 'stage_2_date': datetime.utcnow().isoformat()}
else:
batch_processing.status = BatchProcessing.BatchProcessingStatus.WITHDRAWN
batch_processing.notes = 'Moved back into good standing'
Expand Down Expand Up @@ -320,13 +324,16 @@ async def stage_3_process(app: Flask, qsm: QueueService):
batch_processing.business_identifier,
InvoluntaryDissolutionService.EligibilityFilters(exclude_in_dissolution=False)
)
batch_processing.last_modified = datetime.utcnow()
if eligible:
filing = create_invountary_dissolution_filing(batch_processing.business_id)
app.logger.debug(f'Created Involuntary Dissolution Filing with ID: {filing.id}')
batch_processing.filing_id = filing.id
batch_processing.step = BatchProcessing.BatchProcessingStep.DISSOLUTION
batch_processing.status = BatchProcessing.BatchProcessingStatus.QUEUED
batch_processing.last_modified = datetime.utcnow()
if batch_processing.meta_data is None:
batch_processing.meta_data = {}
batch_processing.meta_data = {**batch_processing.meta_data, 'stage_3_date': datetime.utcnow().isoformat()}
batch_processing.save()

await put_filing_on_queue(filing.id, app, qsm)
Expand All @@ -337,7 +344,6 @@ async def stage_3_process(app: Flask, qsm: QueueService):
else:
batch_processing.status = BatchProcessing.BatchProcessingStatus.WITHDRAWN
batch_processing.notes = 'Moved back into good standing'
batch_processing.last_modified = datetime.utcnow()
batch_processing.save()

mark_eligible_batches_completed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def test_stage_1_process(app, session):
assert batch_processing.created_date.date() == datetime.now().date()
assert batch_processing.trigger_date.date() == datetime.now().date() + datedelta(days=42)
assert batch_processing.meta_data
assert batch_processing.meta_data['stage_1_date']


@pytest.mark.parametrize(
Expand Down Expand Up @@ -306,6 +307,7 @@ def test_stage_2_process_update_business(app, session, test_name, status, step,

if test_name == 'MOVE_2_STAGE_2_SUCCESS':
assert batch_processing.trigger_date.date() == datetime.utcnow().date() + datedelta(days=30)
assert batch_processing.meta_data['stage_2_date']
else:
assert batch_processing.trigger_date == TRIGGER_DATE

Expand Down Expand Up @@ -365,6 +367,7 @@ async def test_stage_3_process(app, session, test_name, status, step, furnishing
mock_put_filing_on_queue.assert_called()
assert batch_processing.filing_id
assert batch.status == Batch.BatchStatus.PROCESSING
assert batch_processing.meta_data['stage_3_date']
elif test_name == 'DISSOLVE_BUSINESS_FAILED':
assert batch.status == Batch.BatchStatus.PROCESSING
assert batch_processing.notes == 'stage 2 intent to dissolve data has not been sent'
Expand Down

0 comments on commit 91f3451

Please sign in to comment.