heroku?
This commit is contained in:
parent
7f1682c04f
commit
846b1fd979
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
|||||||
|
db.*
|
||||||
|
*.sqlite*
|
||||||
node_modules
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
|
Binary file not shown.
Binary file not shown.
1
index.js
Executable file → Normal file
1
index.js
Executable file → Normal file
@ -36,7 +36,6 @@ app.get('/', function (req, res) {
|
|||||||
"LEFT JOIN images AS i ON i.id = q.id " +
|
"LEFT JOIN images AS i ON i.id = q.id " +
|
||||||
"ORDER BY T2.id DESC",
|
"ORDER BY T2.id DESC",
|
||||||
function (err, rows) {
|
function (err, rows) {
|
||||||
//console.log('selected rows:', rows.length);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('error:', err);
|
console.log('error:', err);
|
||||||
res.sendStatus(500);
|
res.sendStatus(500);
|
||||||
|
0
package.json
Executable file → Normal file
0
package.json
Executable file → Normal file
25
sql.js
25
sql.js
@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
const CREATE_TABLE_IMAGES = "CREATE TABLE IF NOT EXISTS images (id INTEGER PRIMARY KEY, src TEXT, dataUri TEXT)";
|
|
||||||
const CREATE_TABLE_QUESTIONS = "CREATE TABLE IF NOT EXISTS questions (id INTEGER PRIMARY KEY, updated DATETIME DEFAULT CURRENT_TIMESTAMP, text TEXT)";
|
|
||||||
const CREATE_TABLE_ANSWERS = "CREATE TABLE IF NOT EXISTS answers (id INTEGER PRIMARY KEY, aid INTEGER, qid INTEGER, text TEXT, correct INTEGER, checked INTEGER)";
|
|
||||||
const CREATE_TABLE_ANSWERING = "CREATE TABLE IF NOT EXISTS answering (id INTEGER PRIMARY KEY, created DATETIME DEFAULT CURRENT_TIMESTAMP, version TEXT, href TEXT)";
|
|
||||||
|
|
||||||
const SELECT_ALL = "SELECT q.id AS qid, q.text AS question, i.dataUri AS image, T2.id AS aid, T2.text AS answer, T2.correct FROM questions q \
|
|
||||||
LEFT JOIN (SELECT qid, MAX(aid) AS maxid FROM answers GROUP BY qid) AS T1 ON q.id = T1.qid \
|
|
||||||
LEFT JOIN answers AS T2 ON T2.aid = T1.maxid AND T2.qid = q.id \
|
|
||||||
LEFT JOIN images AS i ON i.id = q.id ORDER BY T2.id DESC";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
SELECT_ALL: SELECT_ALL
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
app.get('/top-mistakes', function (req, res) {
|
|
||||||
db.all("SELECT q.id AS qid, q.text as question, a.acount AS mistakes FROM questions q " +
|
|
||||||
"JOIN (SELECT qid, count(*) as acount FROM answers WHERE correct != checked GROUP BY aid,qid) AS a ON a.qid = q.id ORDER BY mistakes DESC",
|
|
||||||
function (err, rows) {
|
|
||||||
res.render('index', { questions: rows });
|
|
||||||
});
|
|
||||||
});
|
|
38
tampermonkey2.js
Normal file
38
tampermonkey2.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// ==UserScript==
|
||||||
|
// @name Walker
|
||||||
|
// @namespace http://tampermonkey.net/
|
||||||
|
// @version 0.1
|
||||||
|
// @description try to take over the world!
|
||||||
|
// @author You
|
||||||
|
// @match http://localhost:8080/*
|
||||||
|
// @grant none
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var submit = document.querySelector('input[value=Kontrolli]');
|
||||||
|
var reset = document.querySelector('input[value=Uuesti]');
|
||||||
|
|
||||||
|
function getRandomInt(min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (submit) {
|
||||||
|
console.log('submit form');
|
||||||
|
Array.prototype.slice.call(document.querySelectorAll('table.popup input[type="checkbox"]')).forEach(function(cb) {
|
||||||
|
var checked = !Math.floor(Math.random()*2);
|
||||||
|
cb.checked = checked;
|
||||||
|
console.log(cb.value, checked);
|
||||||
|
});
|
||||||
|
setTimeout(function () {
|
||||||
|
submit.click()
|
||||||
|
}, getRandomInt(30000, 60000));
|
||||||
|
} else if (reset) {
|
||||||
|
console.log('reset form');
|
||||||
|
setTimeout(function () {
|
||||||
|
reset.click()
|
||||||
|
}, getRandomInt(10000, 30000));
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
Loading…
Reference in New Issue
Block a user