Skip to content

Commit

Permalink
chore: Update consts.js to use array of arrays for places
Browse files Browse the repository at this point in the history
This commit updates the consts.js file to use an array of arrays for the places constant instead of an object. This change improves the readability and maintainability of the code.
  • Loading branch information
azat-ismagilov committed Aug 2, 2024
1 parent c638d0d commit dfe2150
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 169 deletions.
54 changes: 24 additions & 30 deletions data/consts.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
export const years = [
"2023", "2022", "2021", "2020", "2019", "2018", "2017", "2016", "2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001"
export const places = [
["2023", "Luxor, Egypt, 47th", "World Finals"],
["2022", "Luxor, Egypt, 46th", "World Finals"],
["2021", "Dhaka, Bangladesh", "World Finals"],
["2020", "Moscow, Russia", "World Finals"],
["2019", "Porto, Portugal", "World Finals"],
["2018", "Beijing, China", "World Finals"],
["2017", "Rapid City, SD, USA", "World Finals"],
["2016", "Phuket, Thailand", "World Finals"],
["2015", "Marrakesh, Morocco", "World Finals"],
["2014", "Ekaterinburg, Russia", "World Finals"],
["2013", "Saint Petersburg, Russia", "World Finals"],
["2012", "Warsaw, Poland", "World Finals"],
["2011", "Orlando FL, USA", "World Finals"],
["2010", "Harbin, China", "World Finals"],
["2009", "Stockholm, Sweden", "World Finals"],
["2008", "Banff, Canada", "World Finals"],
["2007", "Tokyo, Japan", "World Finals"],
["2006", "San Antonio, TX, USA", "World Finals"],
["2005", "Shanghai, China", "World Finals"],
["2004", "Prague, Czech Republic", "World Finals"],
["2003", "Beverly Hills, CA, USA", "World Finals"],
["2002", "Honolulu, Hawaii, USA", "World Finals"],
["2001", "Vancouver, Canada", "World Finals"]
];
export const places =
{
"2023": "Luxor, Egypt, 47th",
"2022": "Luxor, Egypt, 46th",
"2021": "Dhaka, Bangladesh",
"2020": "Moscow, Russia",
"2019": "Porto, Portugal",
"2018": "Beijing, China",
"2017": "Rapid City, SD, USA",
"2016": "Phuket, Thailand",
"2015": "Marrakesh, Morocco",
"2014": "Ekaterinburg, Russia",
"2013": "Saint Petersburg, Russia",
"2012": "Warsaw, Poland",
"2011": "Orlando FL, USA",
"2010": "Harbin, China",
"2009": "Stockholm, Sweden",
"2008": "Banff, Canada",
"2007": "Tokyo, Japan",
"2006": "San Antonio, TX, USA",
"2005": "Shanghai, China",
"2004": "Prague, Czech Republic",
"2003": "Beverly Hills, CA, USA",
"2002": "Honolulu, Hawaii, USA",
"2001": "Vancouver, Canada",
}
;


export const api_key = "d30033b3d833adaace90f8487da70bba";
Expand All @@ -49,5 +44,4 @@ export const SVG_HEIGHT = 60;

export const PER_PAGE = 25;
export const LAST_YEAR = "2023";
export const CONTEST_NAME = "World Finals";
export const DEFAULT_EVENT = "Photo Tour";
12 changes: 3 additions & 9 deletions dataACPC/consts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
export const years = [
"RC 2023-2024", "2023"
export const places = [
["RC 2023-2024", "Regional Contests", ""],
["2023", "", ""]
];
export const places =
{
"RC 2023-2024": "Regional Contests",
"2023": ""
}
;


export const api_key = "d30033b3d833adaace90f8487da70bba";
Expand All @@ -28,5 +23,4 @@ export const SVG_HEIGHT = 60;

export const PER_PAGE = 25;
export const LAST_YEAR = "2023";
export const CONTEST_NAME = "";
export const DEFAULT_EVENT = "Photo Tour";
12 changes: 3 additions & 9 deletions dataAE/consts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
export const years = [
"RC 2023-2024", "2023"
export const places = [
["RC 2023-2024", "Regional Contests", ""],
["2023", "", ""]
];
export const places =
{
"RC 2023-2024": "Regional Contests",
"2023": ""
}
;


export const api_key = "d30033b3d833adaace90f8487da70bba";
Expand All @@ -28,5 +23,4 @@ export const SVG_HEIGHT = 60;

export const PER_PAGE = 25;
export const LAST_YEAR = "2023";
export const CONTEST_NAME = "";
export const DEFAULT_EVENT = "Photo Tour";
12 changes: 3 additions & 9 deletions dataAP/consts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
export const years = [
"2024", "RC 2023-2024"
export const places = [
["2024", "", ""],
["RC 2023-2024", "Regional Contests", ""]
];
export const places =
{
"2024": "",
"RC 2023-2024": "Regional Contests"
}
;


export const api_key = "d30033b3d833adaace90f8487da70bba";
Expand All @@ -28,5 +23,4 @@ export const SVG_HEIGHT = 60;

export const PER_PAGE = 25;
export const LAST_YEAR = "2024";
export const CONTEST_NAME = "";
export const DEFAULT_EVENT = "Photo Tour";
12 changes: 3 additions & 9 deletions dataAW/consts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
export const years = [
"RC 2023-2024", "2023"
export const places = [
["RC 2023-2024", "Regional Contests", ""],
["2023", "", ""]
];
export const places =
{
"RC 2023-2024": "Regional Contests",
"2023": ""
}
;


export const api_key = "d30033b3d833adaace90f8487da70bba";
Expand All @@ -28,5 +23,4 @@ export const SVG_HEIGHT = 60;

export const PER_PAGE = 25;
export const LAST_YEAR = "2023";
export const CONTEST_NAME = "";
export const DEFAULT_EVENT = "Photo Tour";
12 changes: 3 additions & 9 deletions dataEU/consts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
export const years = [
"2024", "RC 2023-2024"
export const places = [
["2024", "EUC, Prague", ""],
["RC 2023-2024", "Regional Contests", ""]
];
export const places =
{
"2024": "EUC, Prague",
"RC 2023-2024": "Regional Contests"
}
;


export const api_key = "d30033b3d833adaace90f8487da70bba";
Expand All @@ -28,5 +23,4 @@ export const SVG_HEIGHT = 60;

export const PER_PAGE = 25;
export const LAST_YEAR = "2024";
export const CONTEST_NAME = "";
export const DEFAULT_EVENT = "Photo Tour";
14 changes: 5 additions & 9 deletions dataLAC/consts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
export const years = [
"RC 2023-2024", "2023"
];

export const places =
{
"RC 2023-2024": "Regional Contests",
"2023": ""
}
;
[
["RC 2023-2024", "Regional Contests", ""],
["2023", "", ""]
];


export const api_key = "d30033b3d833adaace90f8487da70bba";
Expand All @@ -28,5 +25,4 @@ export const SVG_HEIGHT = 60;

export const PER_PAGE = 25;
export const LAST_YEAR = "2023";
export const CONTEST_NAME = "";
export const DEFAULT_EVENT = "Photo Tour";
45 changes: 20 additions & 25 deletions dataNAC/consts.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
export const years = [
"2024", "RC 2023-2024","2023","RC 2022-2023","2022", "RC 2021-2022", "2021", "2020", "RC 2019-2020", "RC 2018-2019", "RC 2016-2017", "RC 2015-2016","RC 2014-2015", "2014", "RC 2013-2014", "2013", "RC 2012-2013","RC 2011-2012"

export const places = [
["2024", "NAC, Orlando, FL", ""],
["RC 2023-2024", "Regional Contests", ""],
["2023", "NAC, Orlando, FL", ""],
["RC 2022-2023", "Regional Contests", ""],
["2022", "NAC, Orlando, FL", ""],
["RC 2021-2022", "Regional Contests", ""],
["2021", "NAC, Online", ""],
["2020", "NAC, Atlanta, GA", ""],
["RC 2019-2020", "Contests", ""],
["RC 2018-2019", "Contests", ""],
["RC 2016-2017", "Contests", ""],
["RC 2015-2016", "Contests", ""],
["RC 2014-2015", "Contests", ""],
["2014", "NAIPC", ""],
["RC 2013-2014", "Contests", ""],
["2013", "UCIPC", ""],
["RC 2012-2013", "Contests", ""],
["RC 2011-2012", "Contests", ""]
];
export const places =
{
"2024": "NAC, Orlando, FL",
"RC 2023-2024": "Regional Contests",
"2023": "NAC, Orlando, FL",
"RC 2022-2023": "Regional Contests",
"2022": "NAC, Orlando, FL",
"RC 2021-2022": "Regional Contests",
"2021": "NAC, Online",
"2020": "NAC, Atlanta, GA",
"RC 2019-2020": "Contests",
"RC 2018-2019": "Contests",
"RC 2016-2017": "Contests",
"RC 2015-2016": "Contests",
"RC 2014-2015": "Contests",
"2014": "NAIPC",
"RC 2013-2014": "Contests",
"2013": "UCIPC",
"RC 2012-2013": "Contests",
"RC 2011-2012": "Contests"
}
;


export const api_key = "d30033b3d833adaace90f8487da70bba";
Expand All @@ -44,5 +40,4 @@ export const SVG_HEIGHT = 60;

export const PER_PAGE = 25;
export const LAST_YEAR = "2024";
export const CONTEST_NAME = "";
export const DEFAULT_EVENT = "Photo Tour";
47 changes: 20 additions & 27 deletions dataNERC/consts.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
export const years = [
"2023", "RC 2023-2024", "2022", "RC 2022-2023", "2021", "2020", "2019", "2018", "2017", "2016", "2015", "2014", "2013", "2012", "2011", "2004", "2003", "2001", "2000"
export const places = [
["2023", "SPb, Novosibirsk, Astana, Kutaisi", ""],
["RC 2023-2024", "Regional Contests", ""],
["2022", "SPb, Tinkoff Arena", ""],
["RC 2022-2023", "Regional Contests", ""],
["2021", "SPb, Tinkoff Arena", ""],
["2020", "SPb, My history park", ""],
["2019", "SPb, My history park", ""],
["2018", "SPb, ITMO University", ""],
["2017", "SPb, ITMO University", ""],
["2016", "SPb, ITMO University", ""],
["2015", "SPb, ITMO University", ""],
["2014", "SPb, ITMO University", ""],
["2013", "SPb, ITMO University", ""],
["2012", "SPb, ITMO University", ""],
["2011", "SPb, ITMO University", ""],
["2004", "SPb, Palace of Youth Creativity", ""],
["2003", "SPb, Palace of Youth Creativity", ""],
["2001", "SPb, Palace of Youth Creativity", ""],
["2000", "SPb, Palace of Youth Creativity", ""]
];
export const places =
{
"2023": "SPb, Novosibirsk, Astana, Kutaisi",
"RC 2023-2024": "Regional Contests",
"2022": "SPb, Tinkoff Arena",
"RC 2022-2023": "Regional Contests",
"2021": "SPb, Tinkoff Arena",
"2020": "SPb, My history park",
"2019": "SPb, My history park",
"2018": "SPb, ITMO University",
"2017": "SPb, ITMO University",
"2016": "SPb, ITMO University",
"2015": "SPb, ITMO University",
"2014": "SPb, ITMO University",
"2013": "SPb, ITMO University",
"2012": "SPb, ITMO University",
"2011": "SPb, ITMO University",
"2004": "SPb, Palace of Youth Creativity",
"2003": "SPb, Palace of Youth Creativity",
"2001": "SPb, Palace of Youth Creativity",
"2000": "SPb, Palace of Youth Creativity"
}
;


export const api_key = "d30033b3d833adaace90f8487da70bba";
export const user_id = "141939107@N06";
Expand All @@ -46,5 +40,4 @@ export const SVG_HEIGHT = 60;

export const PER_PAGE = 25;
export const LAST_YEAR = "2023";
export const CONTEST_NAME = "";
export const DEFAULT_EVENT = "Photo Tour";
12 changes: 6 additions & 6 deletions package-lock.json

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

14 changes: 9 additions & 5 deletions src/Util/PhotoLoader.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useEffect, useMemo, useState } from "react";
import axios from "axios";

import { useAppContext } from "../components/AppContext";
import { TAG_ALBUM } from "../consts";
import { places, TAG_ALBUM } from "../consts";

import PhotoService from "./PhotoService";
import UniqueList from "./UniqueList";
Expand Down Expand Up @@ -39,7 +38,7 @@ const usePhotoLoader = () => {
setAxiosCancelController(new AbortController());
}, [data.year, data.event, data.text, data.team, data.person]);


function appendPhotos(photosByEvent, event, photos) {
const appendedEventPhotos = [...(photosByEvent.get(event) || []), ...photos];
return new Map(photosByEvent.set(event, UniqueList(appendedEventPhotos, photo => photo.id)));
Expand All @@ -59,9 +58,14 @@ const usePhotoLoader = () => {
const albumTag = TAG_ALBUM.toLowerCase();
const tag = tags.split(" ").find(tag => tag.startsWith(albumTag));
if (tag === undefined) {
return null;
return "Unknown";
}
const targetTag = tag.replaceAll(albumTag, "");
const found_tag = places.map(({ year }) => year).find((year) => (year.toLowerCase().replace(/[-_\s]/g, "") === targetTag));
if (found_tag === undefined) {
return "Unknown";
}
return tag.replaceAll(albumTag, "");
return found_tag;
}

/**
Expand Down
Loading

0 comments on commit dfe2150

Please sign in to comment.