Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions src/helpers/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const addExtrapolatedSessions = (
end: historyEnd,
extrapolated: true,
consecutive: statsConsecutive(historyStart, historyEnd),
ongoing: false,
},
];
}
Expand All @@ -52,6 +53,7 @@ export const addExtrapolatedSessions = (
end: firstSessionStart,
extrapolated: true,
consecutive: statsConsecutive(historyStart, firstSessionStart),
ongoing: false,
},
]
: [];
Expand All @@ -63,6 +65,7 @@ export const addExtrapolatedSessions = (
end: historyEnd,
extrapolated: true,
consecutive: statsConsecutive(lastSessionEnd, historyEnd),
ongoing: false,
},
]
: [];
Expand All @@ -79,6 +82,7 @@ export const addExtrapolatedSessions = (
end: nextSession.start,
extrapolated: true,
consecutive: statsConsecutive(previousSession.end, nextSession.start),
ongoing: false,
});
}
}
Expand Down
29 changes: 29 additions & 0 deletions src/helpers/session.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
],
history: undefined,
Expand All @@ -56,6 +57,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
],
},
Expand All @@ -67,6 +69,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(13, 12_000),
extrapolated: false,
consecutive: false,
ongoing: false,
},
],
history: [],
Expand All @@ -76,6 +79,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(13, 12_000),
extrapolated: false,
consecutive: false,
ongoing: false,
},
],
},
Expand All @@ -87,6 +91,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
],
history: [makePlayerDataPIT(0, 0)],
Expand All @@ -97,6 +102,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
],
},
Expand All @@ -110,6 +116,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(12, 12_000),
extrapolated: true,
consecutive: false,
ongoing: false,
},
],
},
Expand All @@ -121,6 +128,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(12, 12_000),
extrapolated: false,
consecutive: false,
ongoing: false,
},
],
history: [makePlayerDataPIT(10, 11_000), makePlayerDataPIT(12, 12_000)],
Expand All @@ -130,6 +138,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(12, 12_000),
extrapolated: false,
consecutive: false,
ongoing: false,
},
],
},
Expand All @@ -141,6 +150,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
],
history: [makePlayerDataPIT(8, 9000), makePlayerDataPIT(11, 12_000)],
Expand All @@ -150,12 +160,14 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(10, 11_000),
extrapolated: true,
consecutive: false,
ongoing: false,
},
{
start: makePlayerDataPIT(10, 11_000),
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
],
},
Expand All @@ -167,6 +179,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
],
history: [makePlayerDataPIT(10, 11_000), makePlayerDataPIT(16, 21_000)],
Expand All @@ -176,12 +189,14 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
{
start: makePlayerDataPIT(11, 12_000),
end: makePlayerDataPIT(16, 21_000),
extrapolated: true,
consecutive: false,
ongoing: false,
},
],
},
Expand All @@ -193,6 +208,7 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
],
history: [makePlayerDataPIT(8, 9000), makePlayerDataPIT(16, 21_000)],
Expand All @@ -202,18 +218,21 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(10, 11_000),
extrapolated: true,
consecutive: false,
ongoing: false,
},
{
start: makePlayerDataPIT(10, 11_000),
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
{
start: makePlayerDataPIT(11, 12_000),
end: makePlayerDataPIT(16, 21_000),
extrapolated: true,
consecutive: false,
ongoing: false,
},
],
},
Expand All @@ -225,18 +244,21 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
{
start: makePlayerDataPIT(12, 14_000),
end: makePlayerDataPIT(13, 16_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
{
start: makePlayerDataPIT(14, 17_000),
end: makePlayerDataPIT(15, 18_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
],
history: [makePlayerDataPIT(8, 9000), makePlayerDataPIT(16, 21_000)],
Expand All @@ -246,42 +268,49 @@ describe(addExtrapolatedSessions, () => {
end: makePlayerDataPIT(10, 11_000),
extrapolated: true,
consecutive: false,
ongoing: false,
},
{
start: makePlayerDataPIT(10, 11_000),
end: makePlayerDataPIT(11, 12_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
{
start: makePlayerDataPIT(11, 12_000),
end: makePlayerDataPIT(12, 14_000),
extrapolated: true,
consecutive: true,
ongoing: false,
},
{
start: makePlayerDataPIT(12, 14_000),
end: makePlayerDataPIT(13, 16_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
{
start: makePlayerDataPIT(13, 16_000),
end: makePlayerDataPIT(14, 17_000),
extrapolated: true,
consecutive: true,
ongoing: false,
},
{
start: makePlayerDataPIT(14, 17_000),
end: makePlayerDataPIT(15, 18_000),
extrapolated: false,
consecutive: true,
ongoing: false,
},
{
start: makePlayerDataPIT(15, 18_000),
end: makePlayerDataPIT(16, 21_000),
extrapolated: true,
consecutive: true,
ongoing: false,
},
],
},
Expand Down
1 change: 1 addition & 0 deletions src/mocks/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const makeSession = (
start: makePlayerDataPIT(uuid, startTime, 1),
end: makePlayerDataPIT(uuid, endTime, 2),
consecutive: true,
ongoing: false,
});

export const makeWrappedResponse = (uuid: string, year: number) => {
Expand Down
3 changes: 3 additions & 0 deletions src/queries/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface APISession {
readonly start: APIPlayerDataPIT;
readonly end: APIPlayerDataPIT;
readonly consecutive: boolean;
readonly ongoing: boolean;
}

type APISessions = readonly APISession[];
Expand All @@ -21,6 +22,7 @@ export interface Session {
readonly end: PlayerDataPIT;
readonly extrapolated: boolean;
readonly consecutive: boolean;
readonly ongoing: boolean;
}
export type Sessions = readonly Session[];

Expand All @@ -31,6 +33,7 @@ export const apiToSession = (
start: apiToPlayerDataPIT(apiSession.start),
end: apiToPlayerDataPIT(apiSession.end),
consecutive: apiSession.consecutive,
ongoing: apiSession.ongoing,
extrapolated,
Comment on lines 33 to 37
});

Expand Down