Linted all seasoned scripts.

This commit is contained in:
2018-02-07 13:51:02 +01:00
parent 74d143775b
commit a8ec7acff5
2 changed files with 52 additions and 57 deletions

View File

@@ -1,22 +1,17 @@
const assert = require('assert');
const Stray = require('src/seasoned/stray');
const establishedDatabase = require('src/database/database');
var pythonShell = require('python-shell');
function foo(e) {
throw('Foooo');
}
const pythonShell = require('python-shell');
class StrayRepository {
constructor(database) {
this.database = database || establishedDatabase;
this.queries = {
'read': 'SELECT * FROM stray_eps WHERE id = ?',
'readAll': 'SELECT id, name, season, episode, verified FROM stray_eps',
'readAllFiltered': 'SELECT id, name, season, episode, verified FROM stray_eps WHERE verified = ',
'checkVerified': 'SELECT id FROM stray_eps WHERE verified = 0 AND id = ?',
'verify': 'UPDATE stray_eps SET verified = 1 WHERE id = ?',
read: 'SELECT * FROM stray_eps WHERE id = ?',
readAll: 'SELECT id, name, season, episode, verified FROM stray_eps',
readAllFiltered: 'SELECT id, name, season, episode, verified FROM stray_eps WHERE verified = ',
checkVerified: 'SELECT id FROM stray_eps WHERE verified = 0 AND id = ?',
verify: 'UPDATE stray_eps SET verified = 1 WHERE id = ?',
};
}
@@ -24,11 +19,11 @@ class StrayRepository {
return this.database.get(this.queries.read, strayId).then((row) => {
assert.notEqual(row, undefined, `Could not find list with id ${strayId}.`);
return row;
})
});
}
readAll(verified = null, page = 1) {
var dbSearchQuery = this.queries.readAll;
readAll(verified = null) {
let dbSearchQuery = this.queries.readAll;
if (verified != null) {
dbSearchQuery = this.queries.readAllFiltered + verified.toString();
}
@@ -40,19 +35,19 @@ class StrayRepository {
stray.episode = row.episode;
stray.verified = row.verified;
return stray;
}))
}));
}
verifyStray(strayId) {
return this.database.get(this.queries.checkVerified, strayId).then((row) => {
assert.notEqual(row, undefined, `Stray '${strayId}' already verified.`);
var options = {
const options = {
pythonPath: '/usr/bin/python3',
args: [strayId]
}
args: [strayId],
};
pythonShell.run('../app/moveSeasoned.py', options, function (err, results) {
pythonShell.run('../app/moveSeasoned.py', options, (err, results) => {
if (err) throw err;
// TODO Add error handling!! StrayRepository.ERROR
// results is an array consisting of messages collected during execution
@@ -60,7 +55,7 @@ class StrayRepository {
});
return this.database.run(this.queries.verify, strayId);
})
});
}
}