better timestamps, adapt default config
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Timo Hocker 2020-08-23 14:31:15 +02:00
parent 714110edb0
commit ade5b933d8
4 changed files with 26 additions and 13 deletions

View File

@ -5,6 +5,8 @@
* Created by Timo Hocker <timo@scode.ovh>, August 2020
*/
/* eslint-disable no-sync */
'use strict';
const knex = require ('knex');
@ -13,14 +15,15 @@ const fs = require ('fs');
let db = null;
async function init (use_fake_seed) {
// eslint-disable-next-line no-sync
if (use_fake_seed && fs.existsSync ('db.sqlite'))
// eslint-disable-next-line no-sync
fs.unlinkSync ('db.sqlite');
if (!fs.existsSync ('data'))
fs.mkdirSync ('data');
if (use_fake_seed && fs.existsSync ('data/db.sqlite'))
fs.unlinkSync ('data/db.sqlite');
db = knex ({
client: 'sqlite',
connection: { filename: 'db.sqlite' },
connection: { filename: 'data/db.sqlite' },
migrations: { directory: 'migrations' },
seeds: { directory: 'seeds' },
useNullAsDefault: true

View File

@ -22,9 +22,9 @@ async function create_app (knex) {
function create_log (index, simplex) {
const data = {
num1: faker.random.number (),
num2: simplex.noise2D (index * 0.1, 0),
num3: simplex.noise2D (index * 0.1, 1000)
light: faker.random.number (),
temperature: simplex.noise2D (index * 0.1, 0),
humidity: simplex.noise2D (index * 0.1, 1000)
};
return {
app_id: faker.random.arrayElement (apps),

View File

@ -9,6 +9,11 @@ export default {
sources: [
{
name: 'default',
limit: 140,
offset: 0
},
{
name: 'secondary',
limit: 10,
offset: 0
}
@ -40,13 +45,11 @@ export default {
]
},
{
source: 'default',
source: 'secondary',
type: 'table',
columns: [
'id',
'message',
'data',
'timestamp'
'timestamp',
'data'
]
}
]

View File

@ -41,6 +41,13 @@ export default new Vuex.Store ({
.then ((res) => res.json ())
.then ((json) => json.map ((entry) => {
entry.data = JSON.parse (entry.data);
const time
= (/(?<y>[0-9]+-[0-9]+-[0-9]+)T(?<t>[0-9]+:[0-9]+:[0-9]+)/u)
.exec (
new Date (entry.timestamp)
.toISOString ()
);
entry.timestamp = `${time.groups.y} ${time.groups.t}`;
return entry;
}));
logs[source.name] = log;