allow Moon in ranking and fix lint errors in ranking.js
This commit is contained in:
parent
173ad407ce
commit
33bbd619c2
|
@ -25,20 +25,54 @@ class Ranks {
|
||||||
|
|
||||||
async updateRanking() {
|
async updateRanking() {
|
||||||
// recalculate ranking column
|
// recalculate ranking column
|
||||||
await Model.query('SET @r=0; UPDATE Users SET ranking= @r:= (@r + 1) WHERE NOT id= 18 ORDER BY totalPixels DESC;');
|
await Model.query(
|
||||||
await Model.query('SET @r=0; UPDATE Users SET dailyRanking= @r:= (@r + 1) WHERE NOT id= 18 ORDER BY dailyTotalPixels DESC;');
|
// eslint-disable-next-line max-len
|
||||||
|
'SET @r=0; UPDATE Users SET ranking= @r:= (@r + 1) ORDER BY totalPixels DESC;',
|
||||||
|
);
|
||||||
|
await Model.query(
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
'SET @r=0; UPDATE Users SET dailyRanking= @r:= (@r + 1) ORDER BY dailyTotalPixels DESC;',
|
||||||
|
);
|
||||||
// populate dictionaries
|
// populate dictionaries
|
||||||
const ranking = await RegUser.findAll({
|
const ranking = await RegUser.findAll({
|
||||||
attributes: ['name', 'totalPixels', 'ranking', 'dailyRanking', 'dailyTotalPixels', [Sequelize.fn('DATEDIFF', Sequelize.literal('CURRENT_TIMESTAMP'), Sequelize.col('createdAt')), 'age']],
|
attributes: [
|
||||||
|
'name',
|
||||||
|
'totalPixels',
|
||||||
|
'ranking',
|
||||||
|
'dailyRanking',
|
||||||
|
'dailyTotalPixels',
|
||||||
|
[
|
||||||
|
Sequelize.fn(
|
||||||
|
'DATEDIFF',
|
||||||
|
Sequelize.literal('CURRENT_TIMESTAMP'),
|
||||||
|
Sequelize.col('createdAt'),
|
||||||
|
),
|
||||||
|
'age',
|
||||||
|
],
|
||||||
|
],
|
||||||
limit: 100,
|
limit: 100,
|
||||||
where: { id: { [Sequelize.Op.notIn]: [18, 51] } },
|
where: { id: { [Sequelize.Op.notIn]: [51, 1] } },
|
||||||
order: ['ranking'],
|
order: ['ranking'],
|
||||||
raw: true,
|
raw: true,
|
||||||
});
|
});
|
||||||
const dailyRanking = await RegUser.findAll({
|
const dailyRanking = await RegUser.findAll({
|
||||||
attributes: ['name', 'totalPixels', 'ranking', 'dailyRanking', 'dailyTotalPixels', [Sequelize.fn('DATEDIFF', Sequelize.literal('CURRENT_TIMESTAMP'), Sequelize.col('createdAt')), 'age']],
|
attributes: [
|
||||||
|
'name',
|
||||||
|
'totalPixels',
|
||||||
|
'ranking',
|
||||||
|
'dailyRanking',
|
||||||
|
'dailyTotalPixels',
|
||||||
|
[
|
||||||
|
Sequelize.fn(
|
||||||
|
'DATEDIFF',
|
||||||
|
Sequelize.literal('CURRENT_TIMESTAMP'),
|
||||||
|
Sequelize.col('createdAt'),
|
||||||
|
),
|
||||||
|
'age',
|
||||||
|
],
|
||||||
|
],
|
||||||
limit: 100,
|
limit: 100,
|
||||||
where: { id: { [Sequelize.Op.notIn]: [18, 51] } },
|
where: { id: { [Sequelize.Op.notIn]: [51, 1] } },
|
||||||
order: ['dailyRanking'],
|
order: ['dailyRanking'],
|
||||||
raw: true,
|
raw: true,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user