Skip to content

Commit

Permalink
Refactors the profile route and related utils for increased clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
jhogan committed Apr 18, 2019
1 parent 6e140ba commit a7f6180
Show file tree
Hide file tree
Showing 94 changed files with 2,679 additions and 9,447 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"no-param-reassign": [0],
"radix": [0],
"camelcase": [0],
"no-use-before-define": [0],
},
"env": {
"node": true,
Expand Down
208 changes: 0 additions & 208 deletions metadata/top-bottom-codings.js

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"license": "ISC",
"dependencies": {
"apicache": "^1.2.3",
"babel-cli": "^6.26.0",
"body-parser": "^1.18.3",
"compression": "1.7.3",
"cwait": "1.1.1",
"d3": "^4.13.0",
"d3-collection": "^1.0.4",
"dataframe-js": "^1.4.1",
"debug": "^3.1.0",
"dotenv": "^6.0.0",
"express": "^4.16.3",
Expand Down
41 changes: 41 additions & 0 deletions q
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
SELECT
sum,
m,
cv,
universe_sum,
universe_m,
profile,
category,
base,
profile.variable
FROM (
SELECT
--- sum ---
SUM(e) AS sum,
--- m ---
SQRT(SUM(POWER(m, 2))) AS m,
--- cv (uses m & sum, recomputed) ---
(((SQRT(SUM(POWER(m, 2))) / 1.645) / NULLIF(SUM(e), 0)) * 100) AS cv,
profile,
category,
base,
LOWER(variable) as variable
FROM economic p
INNER JOIN factfinder_metadata ffm
ON p.variable = ffm.variablename
WHERE p.geoid IN ('SI05')
AND p.dataset = 'Y2006-2010'
GROUP BY variable, base, category, profile
ORDER BY variable, base, category
) profile
LEFT JOIN (
SELECT
SUM(e) as universe_sum,
SQRT(SUM(POWER(m, 2))) as universe_m,
LOWER(variable) as variable
FROM economic base
WHERE base.dataset = 'Y2006-2010'
GROUP BY variable
) universe
ON profile.variable = universe.variable;

Loading

0 comments on commit a7f6180

Please sign in to comment.