1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-09 11:14:29 +02:00
unleash.unleash/src/test
Jaanus Sellin 4234020b8d
feat: backfill licensed users (#8791)
**This migration introduces a query that calculates the licensed user
counts and inserts them into the licensed_users table.**

**The logic ensures that:**

1. All users created up to a specific date are included as active users
until they are explicitly deleted.
2. Deleted users are excluded after their deletion date, except when
their deletion date falls within the last 30 days or before their
creation date.
3. The migration avoids duplicating data by ensuring records are only
inserted if they don’t already exist in the licensed_users table.


**Logic Breakdown:**

**Identify User Events (user_events):** Extracts email addresses from
user-related events (user-created and user-deleted) and tracks the type
and timestamp of the event. This step ensures the ability to
differentiate between user creation and deletion activities.
**Generate a Date Range (dates):** Creates a continuous range of dates
spanning from the earliest recorded event up to the current date. This
ensures we analyze every date, even those without events.
**Determine Active Users (active_emails):** Links dates with user events
to calculate the status of each email address (active or deleted) on a
given day. This step handles:

- The user's creation date.
- The user's deletion date (if applicable).

**Calculate Daily Active User Counts (result):** 
For each date, counts the distinct email addresses that are active based
on the conditions:

- The user has no deletion date.
- The user's deletion date is within the last 30 days relative to the
current date.
- The user's creation date is before the deletion date.
2024-11-20 09:10:07 +02:00
..
config feat: Disallow repeating last 5 passwords. (#7552) 2024-07-09 16:18:35 +02:00
e2e feat: backfill licensed users (#8791) 2024-11-20 09:10:07 +02:00
examples chore: rename toggle to flag #final (#7146) 2024-05-24 15:07:01 +03:00
fixtures feat: show max count of sessions that users have to an admin (#8781) 2024-11-18 15:15:56 +00:00
arbitraries.test.ts chore: Upgrade to typescript 5.4.2 (#6605) 2024-03-19 10:46:08 +00:00