forked from owid/owid-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExplorerRedirects.ts
224 lines (218 loc) · 10.8 KB
/
ExplorerRedirects.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
import { CoreTable } from "../coreTable/CoreTable.js"
import { ExplorerUrlMigrationId } from "../explorer/urlMigrations/ExplorerUrlMigrations.js"
const explorerRedirectTableMatrix = [
["migrationId", "path", "baseQueryStr"],
[
"legacyToGridCovidExplorer",
"/grapher/total-cases-covid-19",
"zoomToSelection=true&casesMetric=true&totalFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/total-confirmed-cases-of-covid-19",
"zoomToSelection=true&casesMetric=true&totalFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/total-cases-covid-19-who",
"zoomToSelection=true&casesMetric=true&totalFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-cases-covid-19",
"zoomToSelection=true&casesMetric=true&dailyFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-new-confirmed-cases-of-covid-19",
"zoomToSelection=true&casesMetric=true&dailyFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-cases-covid-19-who",
"zoomToSelection=true&casesMetric=true&dailyFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/total-deaths-covid-19",
"zoomToSelection=true&deathsMetric=true&totalFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/total-deaths-covid-19-who",
"zoomToSelection=true&deathsMetric=true&totalFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-deaths-covid-19",
"zoomToSelection=true&deathsMetric=true&dailyFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-new-confirmed-deaths-due-to-covid-19",
"zoomToSelection=true&deathsMetric=true&dailyFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-deaths-covid-19-who",
"zoomToSelection=true&deathsMetric=true&dailyFreq=true&smoothing=0&country=~OWID_WRL&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-confirmed-cases-per-million-since-1-per-million",
"yScale=log&zoomToSelection=true&casesMetric=true&totalFreq=true&aligned=true&perCapita=true&smoothing=0&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-confirmed-deaths-since-5th-death",
"yScale=log&zoomToSelection=true&deathsMetric=true&totalFreq=true&aligned=true&smoothing=0&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-confirmed-deaths-since-10th-death",
"yScale=log&zoomToSelection=true&deathsMetric=true&totalFreq=true&aligned=true&smoothing=0&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-confirmed-cases-since-100th-case",
"yScale=log&zoomToSelection=true&casesMetric=true&totalFreq=true&aligned=true&smoothing=0&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-tests-since-100th-case",
"yScale=log&zoomToSelection=true&casesMetric=true&totalFreq=true&aligned=true&smoothing=0&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/case-fatality-rate-covid-19",
"zoomToSelection=true&time=2020-03-14..&cfrMetric=true&totalFreq=true&aligned=true&smoothing=0&country=OWID_WRL~USA~ITA~BRA~ESP~SWE~DEU~IND~IRN&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/coronavirus-cfr",
"zoomToSelection=true&time=2020-03-14..&cfrMetric=true&totalFreq=true&aligned=true&smoothing=0&country=OWID_WRL~USA~ITA~BRA~ESP~SWE~DEU~IND~IRN&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-deaths-days-since-per-million",
"yScale=log&zoomToSelection=true&deathsMetric=true&totalFreq=true&aligned=true&perCapita=true&smoothing=0&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-confirmed-daily-cases-epidemiological-trajectory",
"yScale=log&zoomToSelection=true&casesMetric=true&dailyFreq=true&aligned=true&smoothing=7&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-confirmed-daily-cases-since-100th-case",
"yScale=log&zoomToSelection=true&casesMetric=true&dailyFreq=true&aligned=true&smoothing=7&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-confirmed-daily-deaths-epidemiological-trajectory",
"yScale=log&zoomToSelection=true&deathsMetric=true&dailyFreq=true&aligned=true&smoothing=7&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-confirmed-cases-since-100th-case",
"yScale=log&zoomToSelection=true&casesMetric=true&totalFreq=true&aligned=true&smoothing=0&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-daily-deaths-trajectory-per-million",
"yScale=log&zoomToSelection=true&deathsMetric=true&dailyFreq=true&aligned=true&perCapita=true&smoothing=7&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/covid-daily-cases-trajectory-per-million",
"yScale=log&zoomToSelection=true&casesMetric=true&dailyFreq=true&aligned=true&perCapita=true&smoothing=7&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/total-tests-per-thousand-since-per-cap-death-threshold",
"yScale=log&zoomToSelection=true&testsMetric=true&totalFreq=true&aligned=true&perCapita=true&smoothing=0&country=&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/total-confirmed-cases-of-covid-19-per-million-people",
"tab=map&zoomToSelection=true&country=GBR~USA~ESP~ITA~BRA~IND~KOR®ion=World&casesMetric=true&interval=total&perCapita=true&smoothing=0&pickerMetric=location&pickerSort=asc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/new-covid-cases-per-million",
"tab=map&zoomToSelection=true&country=GBR~USA~ESP~ITA~BRA~IND~KOR®ion=World&casesMetric=true&interval=daily&perCapita=true&smoothing=0&pickerMetric=location&pickerSort=asc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/total-covid-deaths-per-million",
"tab=map&zoomToSelection=true&country=GBR~USA~ESP~ITA~BRA~IND~KOR®ion=World&deathsMetric=true&interval=total&perCapita=true&smoothing=0&pickerMetric=location&pickerSort=asc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/new-covid-deaths-per-million",
"tab=map&zoomToSelection=true&country=GBR~USA~ESP~ITA~BRA~IND~KOR®ion=World&deathsMetric=true&interval=daily&perCapita=true&smoothing=0&pickerMetric=location&pickerSort=asc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-covid-deaths-per-million-7-day-average",
"zoomToSelection=true&deathsMetric=true&dailyFreq=true&perCapita=true&smoothing=7&country=USA~GBR~ITA~DEU~KOR~ZAF~BRA&pickerMetric=location&pickerSort=asc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-new-confirmed-cases-of-covid-19-tests-per-case",
"yScale=log&zoomToSelection=true&time=2020-02-22..latest&country=®ion=World&casesMetric=true&interval=smoothed&aligned=true&smoothing=7&pickerMetric=total_deaths&pickerSort=desc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-new-confirmed-cases-of-covid-19-per-million-tests-per-case",
"yScale=log&zoomToSelection=true&time=2020-02-22..latest&country=®ion=World&casesMetric=true&interval=smoothed&aligned=true&perCapita=true&smoothing=7&pickerMetric=total_deaths&pickerSort=desc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-covid-cases-7-day",
"zoomToSelection=true&time=2020-10-16..latest&country=USA~IND~GBR~DEU~BRA~MEX®ion=World&casesMetric=true&interval=smoothed&smoothing=7&pickerMetric=total_cases&pickerSort=desc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-covid-cases-7-day-average",
"zoomToSelection=true&time=2020-10-16..latest&country=USA~IND~GBR~DEU~BRA~MEX®ion=World&casesMetric=true&interval=smoothed&smoothing=7&pickerMetric=total_cases&pickerSort=desc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-covid-cases-3-day-average",
"zoomToSelection=true&time=2020-10-16..latest&country=USA~IND~GBR~DEU~BRA~MEX®ion=World&casesMetric=true&interval=smoothed&smoothing=7&pickerMetric=total_cases&pickerSort=desc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-covid-cases-per-million-three-day-avg",
"zoomToSelection=true&time=2020-03-01..latest&country=MEX~IND~USA~ITA~BRA~GBR~FRA~ESP&casesMetric=true&interval=smoothed&perCapita=true&smoothing=7&pickerMetric=total_deaths&pickerSort=desc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/grapher/daily-covid-deaths-per-million-3-day-avg",
"zoomToSelection=true&time=2020-03-01..latest&country=MEX~IND~USA~ITA~BRA~GBR~FRA~ESP&deathsMetric=true&interval=smoothed&perCapita=true&smoothing=7&pickerMetric=total_deaths&pickerSort=desc&hideControls=true",
],
[
"legacyToGridCovidExplorer",
"/coronavirus-data-explorer",
"zoomToSelection=true&time=2020-03-01..latest&country=USA~GBR~CAN~DEU~ITA~IND®ion=World&casesMetric=true&interval=smoothed&perCapita=true&smoothing=7&pickerMetric=location&pickerSort=asc",
],
]
interface RedirectRow {
migrationId: ExplorerUrlMigrationId
path: string
baseQueryStr: string
}
export const explorerRedirectTable = new CoreTable<RedirectRow>(
explorerRedirectTableMatrix
)
const standardizePath = (path: string): string =>
!path.startsWith("/") ? `/${path}` : path
export const getExplorerRedirectForPath = (
path: string
): RedirectRow | undefined => {
path = standardizePath(path)
return explorerRedirectTable.rows.find((redirect) => redirect.path === path)
}
export const isPathRedirectedToExplorer = (path: string) =>
explorerRedirectTable.get("path").uniqValuesAsSet.has(standardizePath(path))