Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Google BigQuery data serving for small snapshot #274

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0caede1
Functions Test
nofurtherinformation Jul 9, 2021
1440bfe
Version fix
nofurtherinformation Jul 20, 2021
da9dafe
Remove Performance
nofurtherinformation Jul 20, 2021
0bdc815
Update cors.js
nofurtherinformation Jul 20, 2021
748fa02
P
nofurtherinformation Jul 21, 2021
56b3920
Big Query test functions
nofurtherinformation Jul 21, 2021
809eaf3
Update query.js
nofurtherinformation Jul 21, 2021
ced9d0e
Update query.js
nofurtherinformation Jul 21, 2021
222d85e
Remove logs
nofurtherinformation Jul 21, 2021
d8b9d5f
Range Bigquery
nofurtherinformation Jul 28, 2021
e592731
Update q.js
nofurtherinformation Jul 28, 2021
e3c9459
Columns fix
nofurtherinformation Jul 28, 2021
b26e82e
Update q.js
nofurtherinformation Jul 28, 2021
21d0123
Update q.js
nofurtherinformation Jul 28, 2021
d27c137
Merge branch 'functions-test' into gbq-integration
nofurtherinformation Aug 18, 2021
3a1ecc4
Update michigan-schools.csv
nofurtherinformation Aug 19, 2021
8892078
Time Series Function
nofurtherinformation Aug 19, 2021
6fdd80b
Create qLastMonth.js
nofurtherinformation Aug 19, 2021
9157557
Snapshot initial load
nofurtherinformation Aug 20, 2021
71ae64d
WIP
nofurtherinformation Aug 25, 2021
3323141
Initial Load to BQ
nofurtherinformation Aug 25, 2021
90a0e29
wip
nofurtherinformation Aug 25, 2021
5449de8
WIP
nofurtherinformation Aug 26, 2021
b811a19
WIP
nofurtherinformation Aug 26, 2021
4eccda5
Line chart fix
nofurtherinformation Aug 26, 2021
c1f2248
WIP
nofurtherinformation Aug 26, 2021
6934967
User Preferences
nofurtherinformation Aug 26, 2021
2dcebfc
Revised Preferences Menu
nofurtherinformation Aug 27, 2021
32bb27b
Saved Days Preference Fix
nofurtherinformation Aug 27, 2021
cfaed00
Update TopPanel.js
nofurtherinformation Aug 27, 2021
6b4f70e
Update VariablePanel.js
nofurtherinformation Aug 27, 2021
f0d7388
Update VariablePanel.js
nofurtherinformation Aug 27, 2021
eac9fe2
Columns update [skip ci]
nofurtherinformation Oct 14, 2021
6db12e4
WIP Selection
nofurtherinformation Oct 18, 2021
efcc551
Update MainLineChart.js
nofurtherinformation Oct 21, 2021
dd68fa0
wip
nofurtherinformation Oct 22, 2021
fb932df
URL Params Support
nofurtherinformation Oct 22, 2021
f7e6d21
Gzip response
nofurtherinformation Oct 25, 2021
6c936cb
Lint
nofurtherinformation Oct 25, 2021
1ee68e8
Lazy load data
nofurtherinformation Oct 25, 2021
ae69107
Styling Attribution and Loading
nofurtherinformation Oct 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions functions/_query.js

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions functions/cors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const cors_proxy = require('cors-anywhere');
const fetch = require('node-fetch');
const createHttpTerminator = require('http-terminator');

const handleResponse = async (response, type) => {
if (type === "json") {
return await response.json()
}

if (type === "csv" || type === "text" || type === "document") {
return await response.text()
}

if (type === "buffer" || type === "pbf"){
return await response.arrayBuffer()
}

if (type ==="blob"){
return await response.blob()
}

return null
}

exports.handler = async (event) => {
try {
if (!event.queryStringParameters.url) return { statusCode: 500, body: JSON.stringify({ error: 'No URL Supplied' })}
if (!event.queryStringParameters.type) return { statusCode: 500, body: JSON.stringify({ error: 'No Data Type Supplied' })}

const port = 8080;
const cors_api_url = `http://localhost:${port}/${event.queryStringParameters.url}`;

const server = cors_proxy.createServer({
originWhitelist: [], // Allow all origins
requireHeader: [],
removeHeaders: ['cookie', 'cookie2']
})
server.listen(port, '0.0.0.0', function() {});

const httpTerminator = createHttpTerminator({
server,
});

const response = await fetch(cors_api_url, {
method: 'GET'
}).then(r => {
httpTerminator.terminate()
return r
}).then( r => r.json());

return { statusCode: 200, body: JSON.stringify({ data: response }) };

} catch (error) {
return {
statusCode: 500,
body: JSON.stringify({ error: 'Failed fetching data' }),
};
}
};
58 changes: 58 additions & 0 deletions functions/countyMoran.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions functions/gzip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const util = require('util')
const zlib = require('zlib')
const gzip = util.promisify(zlib.gzip)

async function gzipResponse(responseEncoded) {
return {
statusCode: 200,
headers: {
'Content-Type': 'application/json',
'Content-Encoding': 'gzip'
},
body: (await gzip(responseEncoded)).toString('base64'),
isBase64Encoded: true,
}
}

module.exports = gzipResponse
Loading