Skip to content

Commit 5e6108c

Browse files
committed
wip
1 parent 7955a26 commit 5e6108c

6 files changed

Lines changed: 38 additions & 14 deletions

File tree

src/domains/attempt/components/attempts-comparison-table/vertical-attempts-comparison-table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export const VerticalAttemptsComparisonTable: Component<AttemptsComparisonTableP
146146
</Show>
147147

148148
{/* Line */}
149-
<Cell column={GRID_FULL_COLUMN} text={`Total PB time (${props.sumTimeRecords.trackCount} tracks)`} css={sTitle} />
149+
<Cell column={GRID_FULL_COLUMN} text={`TimeSheet (${props.sumTimeRecords.trackCount} tracks)`} css={sTitle} />
150150

151151
{/* Line */}
152152
<Cell column={GRID_FULL_COLUMN} text={props.sumTimeRecords.time} css={sTime} />

src/domains/attempt/components/attempts-filter/use-attempts-filter.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ export function useAttemptsFilter<Input extends Record<string, Accessor<Array<At
1818
const tracks = createMemo(() => {
1919
return unique(
2020
Object.values(props.input)
21-
.flatMap((a) => a())
22-
.map((a) => a.raw.track),
21+
.flatMap((attempts) => attempts())
22+
.map((a) => a.raw.track)
23+
.toSorted()
2324
);
2425
});
2526

src/domains/attempt/compositions/use-attempt-manager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ function useAttemptManagerFactory() {
3535
const coins = Coins.get(image, putImageData);
3636

3737
if (!isDefined(time) || !isDefined(coins)) {
38+
<<<<<<< Updated upstream
3839
deferFinalTime();
40+
=======
41+
const isFinished = isFinalTime(time, isPause, rate);
42+
>>>>>>> Stashed changes
3943
return undefined;
4044
}
4145

src/domains/attempt/compositions/use-attempts.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
flat,
99
flatMap,
1010
groupBy,
11-
isDeepEqual,
11+
isDeepEqual, isDefined,
1212
last,
1313
map,
1414
pipe,
@@ -17,7 +17,7 @@ import {
1717
unique,
1818
uniqueBy,
1919
uniqueWith,
20-
values,
20+
values
2121
} from "remeda";
2222
import type { AttemptEntity } from "../../database/schemas/attempt-entity";
2323
import type { AttemptsEntity } from "../../database/schemas/attempts-entity";
@@ -27,7 +27,7 @@ import type { SumTimeRecords } from "../types/sum-time-records";
2727
import { Time } from "../utils/time";
2828
import { createMemo } from "solid-js";
2929

30-
function getRecordsBy<T extends Attempt>(attempts: Array<T>, by: Parameters<typeof groupBy<T>>[0]): Array<T> {
30+
function getRecordsBy(attempts: Array<Attempt>, by: Parameters<typeof groupBy<Attempt>>[0]): Array<Attempt> {
3131
return pipe(
3232
attempts,
3333
groupBy(by),
@@ -140,19 +140,30 @@ function useAttemptsFactory(store: Store<AttemptsEntity>) {
140140
),
141141
);
142142

143-
const getSumTimeRecords = createMemo<SumTimeRecords>(() => {
143+
const getSumRecords = (attempts: Array<Attempt>) => {
144144
return pipe(
145-
getTimeRecords(),
145+
attempts,
146146
uniqueBy((attempt) => attempt.raw.track),
147-
map((record) => Time.parse(record.time ?? "0:00.000") - Time.parse("0:00.000")),
147+
filter((record): record is Attempt & { time: string } => isDefined(record.time)),
148+
map((record) => Time.parse(record.time)),
148149
(times) => {
149150
return {
150-
time: Time.formatH(Time.parse("0:00.000") + sum(times)),
151+
time: Time.formatH(sum(times)),
151152
trackCount: times.length,
152153
};
153154
},
154-
);
155-
});
155+
)
156+
}
157+
158+
const getSumSplitsRecords = createMemo<SumTimeRecords>(() => {
159+
return getSumRecords(getSplitRecords());
160+
})
161+
162+
// TOOD: Appuyer sur le bouton de switch ou appuyer sur le recording peut etre générer un probleme
163+
164+
const getSumTimeRecords = createMemo<SumTimeRecords>(() => {
165+
return getSumRecords(getTimeRecords());
166+
})
156167

157168
const merge = (...attempts: Array<Array<AttemptEntity>>): Array<AttemptEntity> => {
158169
return pipe(
@@ -173,6 +184,7 @@ function useAttemptsFactory(store: Store<AttemptsEntity>) {
173184
getSplitRecordByTrack,
174185
getFlattenRecords,
175186
getSumTimeRecords,
187+
getSumSplitsRecords,
176188
merge,
177189
};
178190
}

src/domains/database/compositions/use-personal-repository.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function usePersonalRepositorySingleton() {
2828
getSplitRecords,
2929
getSplitRecordByTrack,
3030
getSumTimeRecords,
31+
getSumSplitsRecords,
3132
merge,
3233
} = useAttempts(store);
3334

@@ -100,6 +101,7 @@ function usePersonalRepositorySingleton() {
100101
getSplitRecords,
101102
getSplitRecordByTrack,
102103
getSumTimeRecords,
104+
getSumSplitsRecords,
103105
shrink,
104106

105107
// JSON

src/views/results.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,17 @@ export const Results: Component = () => {
4141
<div class={sHeader}>
4242
<AttemptsFilter />
4343
<GridColumn class={sGrid} template="repeat(3, auto)" spacing="small" yAlign="center">
44-
<VerticalDivider />
45-
<Cell text="Sum of all your personal bests" />
44+
<VerticalDivider row={2} />
45+
<Cell text="TimeSheet (PB)" />
4646
<Cell
4747
text={`${personal.getSumTimeRecords().time} (${personal.getSumTimeRecords().trackCount} tracks)`}
4848
css={sTime}
4949
/>
50+
<Cell text="TimeSheet (BPS)" />
51+
<Cell
52+
text={`${personal.getSumSplitsRecords().time} (${personal.getSumSplitsRecords().trackCount} tracks)`}
53+
css={sTime}
54+
/>
5055
</GridColumn>
5156
</div>
5257

0 commit comments

Comments
 (0)