1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

feat: productivity report only for seen users (#9204)

This commit is contained in:
Mateusz Kwasniewski 2025-02-05 10:05:35 +01:00 committed by GitHub
parent bd6a90ffd4
commit ebcbd7b637
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -32,11 +32,13 @@ afterAll(async () => {
});
describe('getSubscribedUsers', () => {
test('returns users that did not unsubscribe', async () => {
test('returns seen users that did not unsubscribe', async () => {
const user1 = await userStore.insert({
email: 'user1@example.com',
name: 'User One',
});
// user seen
await userStore.successfullyLogin(user1);
const user2 = await userStore.insert({
email: 'user2@example.com',
name: 'User Two',
@ -54,11 +56,10 @@ describe('getSubscribedUsers', () => {
const subscribers =
await userSubscriptionsReadModel.getSubscribedUsers(subscription);
expect(subscribers).toHaveLength(2);
expect(subscribers).toHaveLength(1);
expect(subscribers).toEqual(
expect.arrayContaining([
{ email: 'user1@example.com', name: 'User One' },
{ email: 'user3@example.com', name: 'User Three' },
]),
);
});
@ -68,6 +69,7 @@ describe('getSubscribedUsers', () => {
email: 'user7@example.com',
name: 'User Seven',
});
await userStore.successfullyLogin(user);
let subscribers =
await userSubscriptionsReadModel.getSubscribedUsers(subscription);

View File

@ -39,6 +39,7 @@ export class UserSubscriptionsReadModel implements IUserSubscriptionsReadModel {
.whereNotIn('id', unsubscribedUserIdsQuery)
.andWhere('is_service', false)
.andWhere('deleted_at', null)
.andWhereNot('seen_at', null)
.andWhereNot('email', null);
return users.map(mapRowToSubscriber);

View File

@ -46,6 +46,7 @@ test('Subscribe and unsubscribe', async () => {
email: 'test@getunleash.io',
name: 'Sample Name',
});
await userStore.successfullyLogin(user);
const subscribers = await userSubscriptionsReadModel.getSubscribedUsers(
'productivity-report',
@ -79,6 +80,7 @@ test('Event log for subscription actions', async () => {
email: 'test@getunleash.io',
name: 'Sample Name',
});
await userStore.successfullyLogin(user);
await userSubscriptionService.unsubscribe(
user.id,