Commit ad888c24 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Add generate_descriptive_stats.js to scripts & clean it up.

parent f70ae06e
......@@ -31,6 +31,7 @@ node_modules/.bin/babel-node src/scripts/generate_stock_exchanges.js
node_modules/.bin/babel-node src/scripts/generate_securities.js
node_modules/.bin/babel-node src/scripts/generate_daily_price_lists.js
node_modules/.bin/babel-node src/scripts/generate_persons.js
node_modules/.bin/babel-node src/scripts/generate_descriptive_stats.js
```
## Launch server
......
......@@ -5,4 +5,4 @@ node_modules/.bin/babel-node src/scripts/generate_stock_exchanges.js
node_modules/.bin/babel-node src/scripts/generate_securities.js
node_modules/.bin/babel-node src/scripts/generate_daily_price_lists.js
node_modules/.bin/babel-node src/scripts/generate_persons.js
node_modules/.bin/babel-node src/scripts/generate_descriptive_stats.js
import assert from "assert"
import fs from "fs"
import path from "path"
import oracledb from "oracledb"
import path from "path"
import { createPool } from "../database"
import { objectsFromSqlResult } from "../model"
......@@ -13,7 +12,9 @@ async function generateStats() {
const connection = await pool.getConnection()
try {
const statsDir = path.join(dataDir, "descriptive_stats")
assert(fs.existsSync(statsDir), `Descriptive stats directory not found: ${statsDir}`)
if (!fs.existsSync(statsDir)) {
fs.mkdirSync(statsDir)
}
console.log("Loading Years List...")
const yearsList = objectsFromSqlResult(
......@@ -38,7 +39,7 @@ async function generateStats() {
for (let year of yearsList) {
{
console.log("Processing year "+year+"...")
console.log("Processing year " + year + "...")
{
//ShareCount
//console.log("Loading Share Count...")
......@@ -390,7 +391,7 @@ async function generateStats() {
}
}
console.log(stats)
// console.log(JSON.stringify(stats, null, 2))
// Write stats in JSON file.
const statsFilename = "descriptive_stats.json"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment