Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

[#177116930] Add EYCA expiration process #41

Merged
merged 6 commits into from
Mar 31, 2021

Conversation

AleDore
Copy link
Contributor

@AleDore AleDore commented Mar 26, 2021

List of Changes

  • Add UpdateExpiredEyca trigger
  • Add ExpireEycaOrchestrator
  • Add ExpireEycaActivity
  • Add tests and refactor some utility modules

Motivation and Context

n EYCA card must expires after a citizen has reached 31 years old, so it' necessary to schedule a trigger that could do this job, intended for:

  • Read from a table which fiscalCodes reaches card expiration on the current day (It is filled during the EYCA's activation)
  • Update EYCA card status to EXPIRED
  • Send proper message to citizen with all the infos about EYCA expiration

Please refer to related story for further informations.

How Has This Been Tested?

It has been tested by performing unit tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@pagopa-github-bot
Copy link
Contributor

pagopa-github-bot commented Mar 26, 2021

Warnings
⚠️ This PR changes a total of 853 LOCs, that is more than a reasonable size of 250. Consider splitting the pull request into smaller ones.

Affected stories

  • 🌟 #177116930: Come GIOVANE, voglio che la scadenza dell' adesione della mia CGN al circuito EYCA, mi venga notificata automaticamente il giorno della scadenza.

Generated by 🚫 dangerJS against 892c5bb

@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #41 (892c5bb) into master (f348113) will increase coverage by 1.65%.
The diff coverage is 87.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #41      +/-   ##
==========================================
+ Coverage   82.89%   84.55%   +1.65%     
==========================================
  Files          36       43       +7     
  Lines        1076     1347     +271     
  Branches      121      145      +24     
==========================================
+ Hits          892     1139     +247     
- Misses        179      203      +24     
  Partials        5        5              
Impacted Files Coverage Δ
utils/activation.ts 75.00% <0.00%> (-3.27%) ⬇️
utils/models.ts 66.66% <ø> (ø)
utils/cgnCode.ts 68.96% <38.46%> (-24.79%) ⬇️
GetEycaStatus/handler.ts 88.23% <50.00%> (ø)
StartEycaActivation/handler.ts 87.01% <50.00%> (ø)
StartCgnActivation/handler.ts 78.20% <55.55%> (ø)
utils/config.ts 63.15% <60.00%> (-6.85%) ⬇️
utils/card_expiration.ts 47.61% <66.66%> (ø)
UpdateCgnOrchestrator/handler.ts 69.86% <69.86%> (ø)
utils/messages.ts 83.33% <75.00%> (-1.67%) ⬇️
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff2130e...892c5bb. Read the comment docs.

Comment on lines 97 to 107
// tslint:disable-next-line: readonly-array
const taskArray = [];
const tasksChunks = chunksOf(tasks, 100);
for (const tasksChunk of tasksChunks) {
taskArray.push(
array
.sequence(taskEither)(tasksChunk)
.run()
);
}
return Promise.all([...taskArray]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer immutable array when possible

Suggested change
// tslint:disable-next-line: readonly-array
const taskArray = [];
const tasksChunks = chunksOf(tasks, 100);
for (const tasksChunk of tasksChunks) {
taskArray.push(
array
.sequence(taskEither)(tasksChunk)
.run()
);
}
return Promise.all([...taskArray]);
return Promise.all(
chunksOf(tasks, 100).map(_ =>
array
.sequence(taskEither)(_)
.run()
)
);

UpdateExpiredEyca/handler.ts Outdated Show resolved Hide resolved
UpdateExpiredEyca/handler.ts Outdated Show resolved Hide resolved
ExpireEycaOrchestrator/function.json Outdated Show resolved Hide resolved
// Now we try to start Expire operation
return tryCatch(
() =>
client.startNew(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the orchestration start fail? We have no retry here and the card remains unapdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a good point. I guess that in this case we must raise an alert with trackException below and proceed to change the state with a script. Another possibility is to create a queue that can retry the expiration process. What do you think about?

@AleDore AleDore requested a review from BurnedMarshal March 29, 2021 15:27
Copy link

@BurnedMarshal BurnedMarshal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart some minor unit tests improvements

ExpireEycaOrchestrator/__tests__/index.test.ts Outdated Show resolved Hide resolved
ExpireEycaOrchestrator/__tests__/index.test.ts Outdated Show resolved Hide resolved
UpdateExpiredEyca/__tests__/handler.test.ts Show resolved Hide resolved
UpdateExpiredEyca/__tests__/handler.test.ts Show resolved Hide resolved
@AleDore AleDore requested a review from BurnedMarshal March 31, 2021 12:43
Copy link

@BurnedMarshal BurnedMarshal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AleDore AleDore merged commit e6185fb into master Mar 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants