Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include episode numbers in Animal Quest default export #62

Merged
merged 2 commits into from
Mar 31, 2024
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: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alveusgg/data",
"version": "0.32.0",
"version": "0.33.0",
"private": true,
"license": "SEE LICENSE IN LICENSE.md",
"repository": {
Expand Down
19 changes: 13 additions & 6 deletions src/animal-quest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ const animalQuest: Readonly<AnimalQuest[]> = [
{
video: {
id: 2104220666, // Original: 1252271923
start: "00h23m00s",
start: "00h22m55s",
},
edition: "African Bullfrog Edition",
description:
"Get to know Georgie, Alveus' African Bullfrog ambassador, and learn about the threats amphibians face in the wild, such as the wildlife trade, habitat loss due to climate change, absorbing pollutants through their skin, and chytrid fungus.",
broadcast: new Date("2024-03-28"),
host: "maya",
length: 51 * 60 + 57, // 00:23:00 - 01:14:57
length: 52 * 60 + 2, // 00:22:55 - 01:14:57
prezi: "Ke6vGrrEBdsbIO5gDY01",
ambassadors: {
featured: ["georgie"],
Expand Down Expand Up @@ -413,6 +413,13 @@ export type AnimalQuestWithEpisode = AnimalQuest & {
episode: number;
};

const animalQuestEpisodes: Readonly<AnimalQuestWithEpisode[]> = animalQuest.map(
(quest, index) => ({
...quest,
episode: index + 1,
}),
);

export type AnimalQuestWithRelation = AnimalQuestWithEpisode & {
relation: "featured" | "related";
};
Expand All @@ -426,11 +433,11 @@ export const getAmbassadorEpisodes = (
// Find all the episodes that have the ambassador featured or related
const featured: AnimalQuestWithRelation[] = [];
const related: AnimalQuestWithRelation[] = [];
for (const [index, quest] of animalQuest.entries()) {
for (const quest of animalQuestEpisodes) {
if (quest.ambassadors.featured.includes(ambassador))
featured.push({ ...quest, episode: index + 1, relation: "featured" });
featured.push({ ...quest, relation: "featured" });
if (quest.ambassadors.related.includes(ambassador))
related.push({ ...quest, episode: index + 1, relation: "related" });
related.push({ ...quest, relation: "related" });
}

// If we're looking for a specific type, and we found it, return it
Expand All @@ -442,4 +449,4 @@ export const getAmbassadorEpisodes = (
return [related[0], ...related.slice(1)];
};

export default animalQuest;
export default animalQuestEpisodes;
Loading