SudoSOS Back-end API / service/wrapped-service / WrappedService
Class: WrappedService ​
Service responsible for computing and updating the "Wrapped" overview information for users (transaction counts, percentiles, heatmaps, etc.).
It extends WithManager to get a transactional EntityManager instance.
Extends ​
Constructors ​
Constructor ​
new WrappedService(manager?): WrappedService;Parameters ​
| Parameter | Type |
|---|---|
manager? | EntityManager |
Returns ​
WrappedService
Inherited from ​
Properties ​
| Property | Modifier | Type | Inherited from |
|---|---|---|---|
manager | protected | EntityManager | WithManager.manager |
Methods ​
getWrappedForUser() ​
getWrappedForUser(userId): Promise<Wrapped>;Fetch the Wrapped row for a single user and map it to the public response shape.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
userId | number | database id of the user to fetch |
Returns ​
Promise<Wrapped>
the Wrapped for the user
updateTransactionDayStats() ​
updateTransactionDayStats(rows, wrappedYear): Promise<void>;Compute per-day statistics for transactions in the given year and update the Wrapped rows with a heatmap and the date with the most transactions.
The heatmap is a 365-length array where index 0 corresponds to Jan 1st.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
rows | Wrapped[] | list of Wrapped rows to operate on |
wrappedYear | number | year for the Wrapped computation |
Returns ​
Promise<void>
updateWrapped() ​
updateWrapped(params?): Promise<void>;Create or update Wrapped rows for users and run all per-user update computation steps (transaction counts, day stats, percentiles, etc.).
If params.ids is provided, the operation is limited to those user ids.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
params | UpdateWrappedParameters | optional filter with specific user ids to update |
Returns ​
Promise<void>
asWrappedResponse() ​
static asWrappedResponse(data): WrappedResponse;Map internal Wrapped entity to the external response DTO.
This method normalizes nullable numeric values and parses stored JSON heatmap strings into number arrays.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
data | Wrapped | Wrapped entity from the database |