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

View File

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

View File

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

View File

@ -41,6 +41,13 @@ export default new Vuex.Store ({
.then ((res) => res.json ()) .then ((res) => res.json ())
.then ((json) => json.map ((entry) => { .then ((json) => json.map ((entry) => {
entry.data = JSON.parse (entry.data); 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; return entry;
})); }));
logs[source.name] = log; logs[source.name] = log;