Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#IOCIT-105] added servicesPreferences to profile data download #191

Merged
merged 6 commits into from
Sep 12, 2022

Conversation

arcogabbo
Copy link
Contributor

@arcogabbo arcogabbo commented Aug 25, 2022

List of Changes

Added servicesPreferences field to AllUserData type
I did a mini refactor on the pipeline for the user data fetch replacing some sequenceS with bind structure where parallel tasks wasn't needed

Motivation and Context

At the moment the servicesPreferences of a profile are not being added to the data a user downloads their data

How Has This Been Tested?

The entire flow of adding some preferences and downloading the data was tested through the io-mock project
Tests passing
The delete procedure already eliminates the preferences, so testing wasn't needed in that front.

Screenshots (if appropriate):

Types of changes

  • Chore (nothing changes by a user perspective)
  • 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.

@arcogabbo arcogabbo requested a review from a team as a code owner August 25, 2022 09:35
@arcogabbo arcogabbo requested review from michaeldisaro and domenicoventriglia and removed request for a team August 25, 2022 09:35
@pagopa-github-bot
Copy link
Contributor

Warnings
⚠️

Please include a Pivotal story at the beginning of the PR title (see below).

Example of PR titles that include pivotal stories:

  • single story: [#123456] my PR title
  • multiple stories: [#123456,#123457,#123458] my PR title

Generated by 🚫 dangerJS

utils/userData.ts Outdated Show resolved Hide resolved
ExtractUserDataActivity/handler.ts Outdated Show resolved Hide resolved
ExtractUserDataActivity/handler.ts Outdated Show resolved Hide resolved
ExtractUserDataActivity/handler.ts Outdated Show resolved Hide resolved
ExtractUserDataActivity/handler.ts Show resolved Hide resolved
ExtractUserDataActivity/handler.ts Outdated Show resolved Hide resolved
ExtractUserDataActivity/handler.ts Outdated Show resolved Hide resolved
utils/userData.ts Outdated Show resolved Hide resolved
@@ -255,7 +291,8 @@ describe("createExtractUserDataActivityHandler", () => {
notificationStatusModel: notificationStatusModelMock,
profileModel: profileModelMock,
userDataBlobService: blobServiceMock,
userDataContainerName: aUserDataContainerName
userDataContainerName: aUserDataContainerName,
servicePreferencesModel
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd maintain coherence keeping or servicePreferencesModel: servicePreferencesModel or servicePreferencesModel alone. Also mocks have usually a "Mock" suffix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 1403000

if (E.isRight(result)) {
expect(result.right).toMatchObject(mockedUserData);
expect(
(result.right.servicesPreferences[0] as any).foo
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could just check that they are equal to aServicePreference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 1403000

servicePreferencesModel.findAllByFiscalCode(fiscalCode),
flattenAsyncIterator,
asyncIteratorToArray,
promise =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just use fromPromiseEither or define something similar?

Copy link
Contributor

@BurnedMarshal BurnedMarshal Sep 7, 2022

Choose a reason for hiding this comment

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

Isn't clear to me what do you mean with fromPromiseEither. In here we have a Promise<ReadonlyArray<Either>> and the Eithers are not relevant in the TE transformation. IMHO the tryCatch is the best method to transform a Promise to a TE where the left value is obtained only on the promise failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i created another function because the promise mentioned above was returning an either[]. done in 1403000

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant that there was a utility function above and maybe we could have adapted it to be more general. The function is using tryCatch but taking it outside the pipe.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that with a separated function the code is less readable in this case, but i leave on you @michaeldisaro @arcogabbo

Copy link
Contributor

Choose a reason for hiding this comment

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

On new functions pls add a detailed JS doc :D

arcogabbo and others added 3 commits September 7, 2022 16:41
Co-authored-by: burnedmarshal <dan.manni@gmail.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 8, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@michaeldisaro michaeldisaro left a comment

Choose a reason for hiding this comment

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

LGTM, to be sure maybe we can just run it on io-mock if possible and check it works as expected.

Copy link
Contributor

@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

@arcogabbo
Copy link
Contributor Author

arcogabbo commented Sep 12, 2022

to be sure maybe we can just run it on io-mock if possible and check it works as expected.

i just run it and it works as expected

@arcogabbo arcogabbo merged commit 4c2125e into master Sep 12, 2022
@arcogabbo arcogabbo deleted the IOCIT-105-download-services-preferences branch September 12, 2022 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants