-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathcanon.js
More file actions
229 lines (223 loc) · 7.55 KB
/
Copy pathcanon.js
File metadata and controls
229 lines (223 loc) · 7.55 KB
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
225
226
227
228
229
const d3Array = require("d3-array");
const {CANON_API, CANON_GEOSERVICE_API} = process ? process.env : {};
const geoRelations = {
children: {
url: id => `${CANON_API}/api/geo/children/${id}/`
},
districts: {
url: id => `${CANON_API}/api/geo/children/${id}/?level=Congressional District`
},
tracts: {
url: id => `${CANON_API}/api/geo/children/${id}/?level=Tract`
},
places: {
url: id => `${CANON_API}/api/geo/children/${id}/?level=Place`
},
childrenCounty: {
url: id => `${CANON_API}/api/geo/childrenCounty/${id}/`
},
neighbors: {
url: id => `${CANON_GEOSERVICE_API}neighbors/${id}`,
callback: resp => {
if (resp.error) {
console.error("[geoservice error]");
console.error(resp.error);
return [];
}
else {
return (resp || []).map(d => d.geoid);
}
}
},
parents: {
url: id => `${CANON_API}/api/parents/geo/${id}`,
callback: arr => arr.map(d => d.id)
},
similar: {
url: id => `${CANON_API}/api/geo/similar/${id}`,
callback: arr => arr.map(d => d.id)
}
};
module.exports = {
db: [
{
host: process.env.CANON_DB_HOST,
name: process.env.CANON_DB_NAME,
user: process.env.CANON_DB_USER,
pass: process.env.CANON_DB_PW,
port: Number(process.env.CANON_DB_PORT) || 5432,
tables: [
require("@datawheel/canon-cms/models"),
require("@datawheel/canon-core/models")
]
},
{
host: process.env.PRISM_DB_HOST || process.env.CANON_DB_HOST,
name: process.env.PRISM_DB_NAME,
user: process.env.PRISM_DB_USER || process.env.CANON_DB_USER,
pass: process.env.PRISM_DB_PW || process.env.CANON_DB_PW,
port: Number(process.env.PRISM_DB_PORT || process.env.CANON_DB_PORT) || 5432,
tables: [
require("./models/prismSubmission")
]
}
],
express: {
set: {
// Canon-core defaults to "loopback"; behind a TLS-terminating LB, req.protocol stays http otherwise.
"trust proxy": 1
}
},
// logiclayer: {
// aliases: {
// "CIP": "cip",
// "Geography": "geo",
// "measures": ["measure", "required"],
// "PUMS Industry": "naics",
// "PUMS Occupation": "soc",
// "University": "university",
// "Year": "year",
// "NAPCS": "napcs"
// },
// cubeFilters: [
// {
// filter: cubes => {
// if (cubes.find(cube => cube.name.includes("_c_"))) {
// cubes = cubes.filter(cube => cube.name.includes("_c_"));
// }
// else if (cubes.find(cube => cube.name.includes("_2016_"))) {
// cubes = cubes.filter(cube => cube.name.includes("_2016_"));
// }
// return cubes.length === 1 ? cubes : cubes.filter(cube => cube.name.match(/_5$/g));
// },
// key: cube => cube.name.replace("_c_", "_").replace("_2016_", "_").replace(/_[0-9]$/g, "")
// },
// {
// filter: cubes => cubes.filter(c => c.name === "ipeds_graduation_demographics_v3"),
// key: cube => !cube ? "test" : cube.name === "ipeds_undergrad_grad_rate_demographics" || cube.name === "ipeds_graduation_demographics_v2" ? "ipeds_graduation_demographics_v3" : cube.name
// }
// ],
// dimensionMap: {
// "CIP2": "CIP",
// "Industry": "PUMS Industry",
// "Commodity L0": "PUMS Industry",
// // "Commodity L1": "PUMS Industry",
// "Industry L0": "PUMS Industry",
// // "Industry L1": "PUMS Industry",
// "Occupation": "PUMS Occupation",
// "OPEID": "University",
// "SCTG2": "NAPCS",
// "Destination State": "Geography",
// "Origin State": "Geography"
// },
// relations: {
// "Destination State": geoRelations,
// "Origin State": geoRelations,
// "Geography": geoRelations,
// "CIP": {
// parents: {
// url: id => `${CANON_API}/api/parents/cip/${id}`,
// callback: arr => arr.map(d => d.id)
// }
// },
// "PUMS Industry": {
// parents: {
// url: id => `${CANON_API}/api/parents/naics/${id}`,
// callback: arr => arr.map(d => d.id)
// }
// },
// "NAPCS": {
// parents: {
// url: id => `${CANON_API}/api/parents/napcs/${id}`,
// callback: arr => arr.map(d => d.id)
// }
// },
// "PUMS Occupation": {
// parents: {
// url: id => `${CANON_API}/api/parents/soc/${id}`,
// callback: arr => arr.map(d => d.id)
// }
// },
// "University": {
// parents: {
// url: id => `${CANON_API}/api/parents/university/${id}`,
// callback: arr => arr.map(d => d.id)
// },
// similar: {
// url: id => `${CANON_API}/api/university/similar/${id}`,
// callback: arr => arr.map(d => d.id)
// }
// }
// },
// substitutions: {
// "Geography": {
// levels: {
// "State": ["Nation"],
// "County": ["MSA", "State", "Origin State", "Destination State", "Nation"],
// "MSA": ["State", "Origin State", "Destination State", "Nation"],
// "Place": ["County", "MSA", "State", "Origin State", "Destination State", "Nation"],
// "PUMA": ["State", "Origin State", "Destination State", "Nation"]
// },
// url: (id, level) => {
// const targetLevel = level.toLowerCase();
// return `${CANON_GEOSERVICE_API}relations/intersects/${id}?targetLevels=${targetLevel}&overlapSize=true`;
// },
// callback: resp => {
// let arr = [];
// if (resp.error) {
// console.error("[geoservice error]");
// console.error(resp.error);
// }
// else {
// arr = resp || [];
// }
// arr = arr.filter(d => d.overlap_size > 0.00001).sort((a, b) => b.overlap_size - a.overlap_size);
// return arr.length ? arr.every(d => d.level === "state") ? arr.filter(d => d.level === "state").map(d => d.geoid) : arr[0].geoid : "01000US";
// }
// },
// "CIP": {
// levels: {
// CIP6: ["CIP4", "CIP2"],
// CIP4: ["CIP2"]
// },
// url: (id, level) => `${CANON_API}/api/cip/parent/${id}/${level}/`,
// callback: resp => resp.id
// },
// "PUMS Industry": {
// levels: {
// "Industry Group": ["Industry", "Industry L0", "Commodity L0"],
// "Industry Sub-Sector": ["Industry", "Industry L0", "Commodity L0"],
// "Industry Sector": ["Industry", "Industry L0", "Commodity L0"]
// },
// url: (id, level) => `${CANON_API}/api/naics/${id}/${level}`,
// callback: resp => resp
// },
// "PUMS Occupation": {
// levels: {
// "Major Occupation Group": ["Occupation"],
// "Minor Occupation Group": ["Occupation"],
// "Broad Occupation": ["Occupation"],
// "Detailed Occupation": ["Occupation"]
// },
// url: id => `${CANON_API}/api/soc/${id}/bls`,
// callback: resp => resp
// },
// "NAPCS": {
// levels: {
// "NAPCS Section": ["SCTG2"],
// "NAPCS Group": ["SCTG2"],
// "NAPCS Class": ["SCTG2"]
// },
// url: id => `${CANON_API}/api/napcs/${id}/sctg/`,
// callback: resp => resp.map(d => d.id)
// },
// "University": {
// levels: {
// University: ["OPEID"]
// },
// url: id => `${CANON_API}/api/university/opeid/${id}/`,
// callback: resp => resp.opeid
// }
// }
// }
};