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