Skip to content

Commit a76215c

Browse files
committed
#282 Update config
1 parent cae868c commit a76215c

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

src/state/State.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export namespace SearchRequest {
5252
}
5353

5454
export type CodeTriCentre = 'date' | 'distance';
55-
export type DoseType = 'covid';
55+
export type DoseType = 'covid' | 'monkeypox';
5656

5757
export type TypePlateforme = "Doctolib"|"Maiia"|"Ordoclic"|"Keldoc"|"Pandalab"|"Mapharma"|"AvecMonDoc"|"Clikodoc"|"mesoigner"|"Bimedoc"|"Valwin";
5858
export type Plateforme = {
@@ -457,7 +457,7 @@ export class State {
457457
const urlGenerator = await RemoteConfig.INSTANCE.urlGenerator();
458458
const [principalLieuxDepartement, ...lieuxDepartementsAditionnels] = await Promise.all(
459459
codesDepartements.map(codeDept => Promise.all([
460-
fetch(urlGenerator.infosDepartement(codeDept), { cache: 'no-cache' })
460+
fetch(urlGenerator.infosDepartement(codeDept, doseType), { cache: 'no-cache' })
461461
.then(resp => resp.json())
462462
.then((statsDept: LieuxParDepartement_JSON) => ({...statsDept, codeDepartement: codeDept} as LieuxParDepartement_JSON & {codeDepartement: string})),
463463
fetch(urlGenerator.creneauxQuotidiensDepartement(codeDept, doseType), { cache: 'no-cache' })

src/utils/LocalConfig.ts

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type DataUrlGenerator = {
44
listDepartements: () => string,
55
statsByDate: () => string,
66
stats: () => string,
7-
infosDepartement: (codeDepartement: string) => string,
7+
infosDepartement: (codeDepartement: string, doseType: DoseType) => string,
88
creneauxQuotidiensDepartement: (codeDepartement: string, doseType: DoseType) => string,
99
};
1010

@@ -13,13 +13,25 @@ export const GITLAB_DATA_URLS: DataUrlGenerator = {
1313
statsByDate: () => `https://vitemadose.gitlab.io/vitemadose/stats_by_date.json`,
1414
stats: () => `https://vitemadose.gitlab.io/vitemadose/stats.json`,
1515
infosDepartement: (codeDepartement) => `https://vitemadose.gitlab.io/vitemadose/${codeDepartement}.json`,
16-
creneauxQuotidiensDepartement: (codeDepartement) => `https://vitemadose.gitlab.io/vitemadose/${codeDepartement}/creneaux-quotidiens.json`
16+
creneauxQuotidiensDepartement: (codeDepartement, doseType) => {
17+
if (doseType == 'covid') {
18+
return `https://vitemadose.gitlab.io/vitemadose/${codeDepartement}/creneaux-quotidiens.json`;
19+
}
20+
21+
return `https://vitemadose.gitlab.io/vitemadose/monkeypox/${codeDepartement}/creneaux-quotidiens.json`;
22+
}
1723
}
1824

1925
export const GITHUB_DATA_URLS: DataUrlGenerator = {
2026
listDepartements: () => `https://raw.githubusercontent.com/CovidTrackerFr/vitemadose/data-auto/data/output/departements.json`,
2127
statsByDate: () => `https://raw.githubusercontent.com/CovidTrackerFr/vitemadose/data-auto/data/output/stats_by_date.json`,
2228
stats: () => `https://raw.githubusercontent.com/CovidTrackerFr/vitemadose/data-auto/data/output/stats.json`,
2329
infosDepartement: (codeDepartement) => `https://raw.githubusercontent.com/CovidTrackerFr/vitemadose/data-auto/data/output/${codeDepartement}.json`,
24-
creneauxQuotidiensDepartement: (codeDepartement) => `https://raw.githubusercontent.com/CovidTrackerFr/vitemadose/data-auto/data/output/${codeDepartement}/creneaux-quotidiens.json`
30+
creneauxQuotidiensDepartement: (codeDepartement,doseType) => {
31+
if (doseType == 'covid') {
32+
return `https://raw.githubusercontent.com/CovidTrackerFr/vitemadose/data-auto/data/output/${codeDepartement}/creneaux-quotidiens.json`
33+
}
34+
35+
return `https://raw.githubusercontent.com/CovidTrackerFr/vitemadose/data-auto/data/output/monkeypox/${codeDepartement}/creneaux-quotidiens.json`
36+
}
2537
}

src/utils/RemoteConfig.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type RemoteConfigEntries = {
88
"data_disclaimer_severity": string,
99
"path_contributors": string,
1010
"path_data_department": string,
11+
"path_monkeypox_data_department": string,
1112
"path_list_departments": string,
1213
"path_stats": string,
1314
"url_base": string,
@@ -22,6 +23,7 @@ const REMOTE_CONFIG_ENTRIES_FALLBACK: RemoteConfigEntries = {
2223
"data_disclaimer_severity": "warning",
2324
"path_contributors": "/vitemadose/contributors_all.json",
2425
"path_data_department": "/vitemadose/{code}.json",
26+
"path_monkeypox_data_department": "/vitemadose/monkeypox/{code}.json",
2527
"path_list_departments": "/vitemadose/departements.json",
2628
"path_stats": "/vitemadose/stats.json",
2729
"url_base": "https://vitemadose.gitlab.io",
@@ -68,7 +70,13 @@ export class RemoteConfig {
6870
statsByDate: () => `/offline/stats_by_date.json`,
6971
stats: () => `/offline/stats.json`,
7072
infosDepartement: (codeDepartement) => `/offline/${codeDepartement}.json`,
71-
creneauxQuotidiensDepartement: (codeDepartement) => `/offline/${codeDepartement}/creneaux-quotidiens.json`
73+
creneauxQuotidiensDepartement: (codeDepartement, doseType) => {
74+
if (doseType == 'covid') {
75+
return `/offline/${codeDepartement}/creneaux-quotidiens.json`;
76+
}
77+
78+
return `/offline/monkeypox/${codeDepartement}/creneaux-quotidiens.json`
79+
}
7280
};
7381
this.configurationSyncedPromise = Promise.resolve();
7482

@@ -105,12 +113,19 @@ export class RemoteConfig {
105113
const statsByDatePath = `/vitemadose/stats_by_date.json`;
106114
const departementsListPath = this.configuration.path_list_departments || `/vitemadose/departements.json`;
107115
const infosDepartementPath = this.configuration.path_data_department || `/vitemadose/{code}.json`;
116+
const monkeypoxDepartmentDataPath = this.configuration.path_monkeypox_data_department || REMOTE_CONFIG_ENTRIES_FALLBACK.path_monkeypox_data_department;
108117
this._urlGenerator = {
109118
listDepartements: () => `${urlBase}${departementsListPath}`,
110119
statsByDate: () => `${urlBase}${statsByDatePath}`,
111120
stats: () => `${urlBase}${statsPath}`,
112-
infosDepartement: (codeDepartement) => `${urlBase}${infosDepartementPath.replace('{code}', codeDepartement)}`,
113-
creneauxQuotidiensDepartement: (codeDepartement) => `${urlBase}/vitemadose/${codeDepartement}/creneaux-quotidiens.json`
121+
infosDepartement: (codeDepartement, doseType) => doseType === 'monkeypox' ? `${urlBase}${monkeypoxDepartmentDataPath.replace('{code}', codeDepartement)}` : `${urlBase}${infosDepartementPath.replace('{code}', codeDepartement)}`,
122+
creneauxQuotidiensDepartement: (codeDepartement, doseType) => {
123+
if (doseType == 'covid') {
124+
return `${urlBase}/vitemadose/${codeDepartement}/creneaux-quotidiens.json`;
125+
}
126+
127+
return `${urlBase}/vitemadose/monkeypox/${codeDepartement}/creneaux-quotidiens.json`;
128+
}
114129
};
115130
} else if(USE_GITLAB_AS_FALLBACK) {
116131
this._urlGenerator = GITLAB_DATA_URLS;

0 commit comments

Comments
 (0)