-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfetchRemovedOutliersData.js
50 lines (45 loc) · 1.99 KB
/
fetchRemovedOutliersData.js
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
const axios = require('axios');
const cookieParser = require('cookie-parser');
const csv2Json = require('./utils/csv2Json')
const fs = require("fs");
const csv = require("fast-csv");
async function fetchMedianFilter(req, res) {
state = req.params.state?.toString();
console.log(state)
// url located the cvs file in data repo
url = "https://raw.githubusercontent.com/NUMBKV/COMP590-Data-Processing/remove-outlier-sean/remove_outlier_cases/median_filter/remove_outlier_" + state + ".csv"
let result = await csv2Json.getJSONFromUrl(url);
if (!result) {
res.send({"error" : "Error: please check state name. For example, california"})
} else {
res.send({medianFilter: result})
}
}
async function fetchCart(req, res) {
state = req.params.state?.toString();
// url located the cvs file in data repo
url = "https://raw.githubusercontent.com/NUMBKV/COMP590-Data-Processing/remove-outlier-sean/remove_outlier_cases/CART/remove_outlier_" + state + ".csv"
let result = await csv2Json.getJSONFromUrl(url);
if (!result) {
res.send({"error" : "Error: please check state name. For example, california"})
} else {
res.send({cartModel: result})
}
}
async function fetchProphet(req, res) {
state = req.params.state?.toString();
// url located the cvs file in data repo
url = "https://raw.githubusercontent.com/NUMBKV/COMP590-Data-Processing/remove-outlier-sean/remove_outlier_cases/Prophet/remove_outlier_" + state + ".csv"
let result = await csv2Json.getJSONFromUrl(url);
if (!result) {
res.send({"error" : "Error: please check state name. For example, california"})
} else {
res.send({prophet: result})
}
}
module.exports = (app) => {
app.get('/removedOutliers/medianFilter/:state', fetchMedianFilter)
app.get('/removedOutliers/cart/:state', fetchCart)
app.get('/removedOutliers/prophet/:state', fetchProphet)
// app.get('/fetchVaccinedData/removeOutliers/cart/:state/:county?', makeVaccineData)
}