-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from johnsyweb/paj/juniors
junior parkrun support
- Loading branch information
Showing
8 changed files
with
107 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { IFinisher } from "../types/Finisher"; | ||
import { MilestoneCelebrations } from "../types/Milestones"; | ||
|
||
export interface JuniorMilestoneDefinition { | ||
restricted_age?: string; | ||
icon: string; | ||
name: string; | ||
} | ||
|
||
export function twoKFinishersToMilestones( | ||
finishers: IFinisher[] | ||
): MilestoneCelebrations[] { | ||
const milestones: Record<number, JuniorMilestoneDefinition> = { | ||
11: { icon: "🟦", restricted_age: "J", name: "Half marathon" }, | ||
21: { icon: "🟩", restricted_age: "J", name: "Marathon" }, | ||
50: { icon: "🟧", restricted_age: "J", name: "Ultra marathon" }, | ||
100: { icon: "⬜", restricted_age: "J", name: "junior parkrun 100" }, | ||
250: { icon: "🟨", restricted_age: "J", name: "junior parkrun 250" }, | ||
}; | ||
|
||
const milestoneCelebrations: MilestoneCelebrations[] = []; | ||
|
||
for (const n in milestones) { | ||
const milestone: JuniorMilestoneDefinition = milestones[n]; | ||
const names: string[] = finishers | ||
.filter( | ||
(f) => | ||
Number(f.runs) === Number(n) && | ||
(!milestone.restricted_age || | ||
f.agegroup?.startsWith(milestone.restricted_age)) | ||
) | ||
.map((f) => f.name); | ||
|
||
if (names.length > 0) { | ||
milestoneCelebrations.push({ | ||
clubName: milestone.name, | ||
icon: milestone.icon, | ||
names, | ||
}); | ||
} | ||
} | ||
return milestoneCelebrations; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { MilestoneCelebrations } from "../types/Milestones"; | ||
import { VolunteerWithCount } from "../types/Volunteer"; | ||
|
||
export function twoKVolunteersToMilestones( | ||
volunteers: VolunteerWithCount[] | ||
): MilestoneCelebrations[] { | ||
const names = volunteers | ||
.filter((v) => v.vols === 5 && v.agegroup?.startsWith("J")) | ||
.map((v) => v.name); | ||
|
||
return names.length | ||
? [ | ||
{ | ||
clubName: "junior parkrun v5", | ||
icon: "💟", | ||
names, | ||
}, | ||
] | ||
: []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,8 @@ | |
background: lightgoldenrodyellow; | ||
padding: 12px; | ||
} | ||
|
||
#eventuate #message { | ||
color: lightcoral; | ||
font-weight: bold; | ||
} |