Skip to content

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 ​

ts
new WrappedService(manager?): WrappedService;

Parameters ​

ParameterType
manager?EntityManager

Returns ​

WrappedService

Inherited from ​

WithManager.constructor

Properties ​

PropertyModifierTypeInherited from
managerprotectedEntityManagerWithManager.manager

Methods ​

getWrappedForUser() ​

ts
getWrappedForUser(userId): Promise<Wrapped>;

Fetch the Wrapped row for a single user and map it to the public response shape.

Parameters ​

ParameterTypeDescription
userIdnumberdatabase id of the user to fetch

Returns ​

Promise<Wrapped>

the Wrapped for the user


updateTransactionDayStats() ​

ts
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 ​

ParameterTypeDescription
rowsWrapped[]list of Wrapped rows to operate on
wrappedYearnumberyear for the Wrapped computation

Returns ​

Promise<void>


updateWrapped() ​

ts
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 ​

ParameterTypeDescription
paramsUpdateWrappedParametersoptional filter with specific user ids to update

Returns ​

Promise<void>


asWrappedResponse() ​

ts
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 ​

ParameterTypeDescription
dataWrappedWrapped entity from the database

Returns ​

WrappedResponse