-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
31 lines (24 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'liquidity'
});
connection.connect();
//CHANGE THIS: Reward devided by the number of hours and minutes in the period.
var reward = 3000000 / 744 / 60;
//CHANGE THESE DATES:
var date = new Date('Mar 1 2021 00:00:00 GMT+0000 (UTC)').getTime();
while(date < new Date('Apr 1 2021 00:00:00 GMT+0000 (UTC)')) {
date += (60 * 1000);
var query = connection.query({
sql: "insert into awards(address, amount) select trans.from, sum(quantity) / (select sum(qty) from (select trans.from, sum(quantity) qty from trans where UnixTimestamp < ? group by trans.from having sum(quantity) > 0) daily_total) * ? award from trans where UnixTimestamp < ? group by trans.from having sum(quantity) > 0",
values: [date.valueOf() / 1000, reward, date.valueOf() / 1000]
},
function (error, results, fields) {
console.log(results);
}
);
}
connection.end();