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

[#175497433] Add Profile unsubscription on feed #86

Merged
merged 4 commits into from
Nov 3, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions GetSubscriptionsFeed/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ export function GetSubscriptionsFeedHandler(
const profileSubscriptionsQuery: PagedQuery = pagedQuery(
queryFilterForKey(`P-${subscriptionsDateUTC}-S`)
);
const profileUnsubscriptionsQuery: PagedQuery = pagedQuery(
queryFilterForKey(`P-${subscriptionsDateUTC}-U`)
);
const serviceSubscriptionsQuery: PagedQuery = pagedQuery(
queryFilterForKey(`S-${subscriptionsDateUTC}-${serviceId}-S`)
);
Expand All @@ -117,6 +120,11 @@ export function GetSubscriptionsFeedHandler(
// users that created their account on date
const profileSubscriptionsSet = await queryUsers(profileSubscriptionsQuery);

// users that deleted their account on date
const profileUnsubscriptionsSet = await queryUsers(
profileUnsubscriptionsQuery
);

// users that subscribed to the client service on date
const serviceSubscriptionsSet = await queryUsers(serviceSubscriptionsQuery);

Expand All @@ -127,14 +135,20 @@ export function GetSubscriptionsFeedHandler(

const subscriptions = new Array<FiscalCodeHash>();
profileSubscriptionsSet.forEach(ps => {
if (!serviceUnsubscriptionsSet.has(ps)) {
if (
!serviceUnsubscriptionsSet.has(ps) &&
!profileUnsubscriptionsSet.has(ps)
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 this check is useless since you either have a profile subscription OR a profile unsubscription but never both in the same day

Copy link
Contributor Author

@AleDore AleDore Nov 2, 2020

Choose a reason for hiding this comment

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

It is true if we mantain 7 delay days between request and effectiveness account's deletion. If we enable instant delete of personal data, it should be possible. What do you think?

Copy link
Contributor

@gunzip gunzip Nov 2, 2020

Choose a reason for hiding this comment

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

I think it's true in any scenario since when you create the (un)subscription record in the same day, you delete any previous (un)subscription here: https://github.com/pagopa/io-functions-app/blob/master/UpdateSubscriptionsFeedActivity/index.ts#L102

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8857930

) {
// add new users to the new subscriptions, skipping those that
// unsubscribed from this service
// unsubscribed from this service or deleted its account
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// unsubscribed from this service or deleted its account
// unsubscribed from this service or deleted their account

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8857930

subscriptions.push(ps);
}
});
serviceSubscriptionsSet.forEach(ss => {
if (!profileSubscriptionsSet.has(ss)) {
if (
!profileSubscriptionsSet.has(ss) &&
!profileUnsubscriptionsSet.has(ss)
) {
// add all users that subscribed to this service, skipping those that
// are new users as they're yet counted in as new subscribers in the
// previous step
Expand All @@ -143,11 +157,20 @@ export function GetSubscriptionsFeedHandler(
});

const unsubscriptions = new Array<FiscalCodeHash>();

profileUnsubscriptionsSet.forEach(pu =>
// add all users that deleted its own account
unsubscriptions.push(pu)
);

serviceUnsubscriptionsSet.forEach(su => {
if (!profileSubscriptionsSet.has(su)) {
if (
!profileSubscriptionsSet.has(su) &&
!profileUnsubscriptionsSet.has(su)
) {
// add all users that unsubscribed from this service, skipping those
// that created the profile on the same day as the service will not
// yet know they exist
// yet know they exist or deleted its account
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// yet know they exist or deleted its account
// yet know they exist or deleted their account

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8857930

unsubscriptions.push(su);
}
});
Expand Down