filter date by symbol, re-organize files a bit

This commit is contained in:
Your Name
2020-04-24 20:39:45 -05:00
parent 5321e2430d
commit 00d4239860
103 changed files with 11 additions and 5 deletions

View File

@@ -40,7 +40,12 @@ module.exports = (req, res) => {
if (func === "/getDates") {
console.log("Request for Dates");
const db = new Database('./quoteDBs/consolidated.sqlite3', { verbose: console.log });
const stmt = db.prepare("SELECT distinct date(TimeStamp,'localtime') Date FROM OptionQuotes order by 1");
let sql = "SELECT distinct date(TimeStamp,'localtime') Date FROM OptionQuotes where 1=1";
if (qsAttr.Symbol) {
sql +=" and Symbol='" + qsAttr.Symbol.mySqlEsc() + "'";
}
sql +=" order by 1";
const stmt = db.prepare(sql);
let allDates = stmt.all();
//console.log(JSON.stringify(allDates));
db.close();
@@ -93,9 +98,10 @@ module.exports = (req, res) => {
// this is very basic protection only...
if ((func.indexOf("..") === -1) && (func.indexOf("~") === -1) && (func.indexOf("favicon ") === -1) ){
res.setHeader('Content-Type', 'text/html');
fs.readFile(".."+func, (err,filecontent)=>{
fs.readFile("../client/"+func, (err,filecontent)=>{
if (err) {
micro.send(res,500,err);
console.log(err);
micro.send(res,500, "Error. check console for details.");
} else {
micro.send(res,200,filecontent);
}