polishing chart, build info in top left
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@ -8,7 +8,6 @@
|
||||
'use strict';
|
||||
|
||||
const faker = require ('faker');
|
||||
const sn = require ('simplex-noise');
|
||||
|
||||
const apps = [];
|
||||
|
||||
@ -20,17 +19,23 @@ async function create_app (knex) {
|
||||
apps.push (id);
|
||||
}
|
||||
|
||||
function create_log (index, simplex) {
|
||||
let last_t = 0;
|
||||
let last_h = 0;
|
||||
|
||||
function create_log (timestamp) {
|
||||
last_t += faker.random.number (3) - 1;
|
||||
last_h += faker.random.number (2) - 1;
|
||||
|
||||
const data = {
|
||||
light: faker.random.number (),
|
||||
temperature: simplex.noise2D (index * 0.1, 0),
|
||||
humidity: simplex.noise2D (index * 0.1, 1000)
|
||||
light: faker.random.number (10),
|
||||
temperature: last_t,
|
||||
humidity: last_h
|
||||
};
|
||||
return {
|
||||
app_id: faker.random.arrayElement (apps),
|
||||
message: faker.random.words (),
|
||||
data: JSON.stringify (data),
|
||||
timestamp: faker.date.recent ()
|
||||
timestamp
|
||||
};
|
||||
}
|
||||
|
||||
@ -41,10 +46,11 @@ async function seed (knex) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await create_app (knex);
|
||||
|
||||
const simplex = (new sn);
|
||||
const log = (Array (20))
|
||||
const log = (Array (1000))
|
||||
.fill (() => null)
|
||||
.map ((a, index) => create_log (index, simplex));
|
||||
.map (() => faker.date.recent (30))
|
||||
.sort ()
|
||||
.map ((t) => create_log (t));
|
||||
|
||||
await knex.batchInsert ('log', log, 10);
|
||||
}
|
||||
|
Reference in New Issue
Block a user