prettier: format all files
parent
0be52437ed
commit
1374ea5ee4
|
@ -1,5 +1,4 @@
|
|||
Contributing
|
||||
============
|
||||
# Contributing
|
||||
|
||||
## I want to contribute code to Lichess
|
||||
|
||||
|
@ -10,7 +9,7 @@ Contributing
|
|||
|
||||
## I want to report a bug or a problem about Lichess
|
||||
|
||||
[__Make an issue__](https://github.com/ornicar/lila/issues/new). However, note that issues that provide little value compared to the required effort may be closed. Before creating an issue, make sure that:
|
||||
[**Make an issue**](https://github.com/ornicar/lila/issues/new). However, note that issues that provide little value compared to the required effort may be closed. Before creating an issue, make sure that:
|
||||
|
||||
1. You list the steps to reproduce the problem to show that other users may experience it as well, if the issue is not self-descriptive.
|
||||
2. Search to make sure it isn't a duplicate. [The advanced search syntax](https://help.github.com/articles/searching-issues/) may come in handy.
|
||||
|
@ -20,12 +19,12 @@ Report mobile-only bugs to [Lichess mobile](https://github.com/veloce/lichobile/
|
|||
|
||||
## I want to suggest a feature for Lichess
|
||||
|
||||
Issue tickets on features that lack potential or effectiveness are not useful and may be closed. Discussions regarding whether a proposed new feature would be useful can be done on the [Lichess Feedback Forum](https://lichess.org/forum/lichess-feedback) to gauge feedback. The developers may also discuss the idea there, and if it is exemplary, a corresponding issue ticket will be made. __When you're ready, [make an issue ticket](https://github.com/ornicar/lila/issues/new)__ and link relevant, constructive comments regarding it in your issue ticket (such as a detailed Reddit post; linking to an empty forum thread with only your own commentary adds no value). Make sure that the feature you propose:
|
||||
Issue tickets on features that lack potential or effectiveness are not useful and may be closed. Discussions regarding whether a proposed new feature would be useful can be done on the [Lichess Feedback Forum](https://lichess.org/forum/lichess-feedback) to gauge feedback. The developers may also discuss the idea there, and if it is exemplary, a corresponding issue ticket will be made. **When you're ready, [make an issue ticket](https://github.com/ornicar/lila/issues/new)** and link relevant, constructive comments regarding it in your issue ticket (such as a detailed Reddit post; linking to an empty forum thread with only your own commentary adds no value). Make sure that the feature you propose:
|
||||
|
||||
1. Is __effective in delivering a goal__. A feature that adds nothing new is purely fancy; please develop a userscript or userstyle for your personal use instead.
|
||||
2. Doesn't rely on mundane assumptions. Non-technical people have the tendency to measure how difficult / easy a feature is to implement based on their unreliable instincts, and such assumptions wastes everyone's time. __Point out what needs to happen__, not what you think will happen.
|
||||
3. Is __unique, if you're aiming to solve a problem__. Features that can easily be replaced by easier ideas have little value and may not have to be brought up to begin with.
|
||||
4. Is __clear and concise__. If ambiguities exist, define them or propose options.
|
||||
1. Is **effective in delivering a goal**. A feature that adds nothing new is purely fancy; please develop a userscript or userstyle for your personal use instead.
|
||||
2. Doesn't rely on mundane assumptions. Non-technical people have the tendency to measure how difficult / easy a feature is to implement based on their unreliable instincts, and such assumptions wastes everyone's time. **Point out what needs to happen**, not what you think will happen.
|
||||
3. Is **unique, if you're aiming to solve a problem**. Features that can easily be replaced by easier ideas have little value and may not have to be brought up to begin with.
|
||||
4. Is **clear and concise**. If ambiguities exist, define them or propose options.
|
||||
|
||||
## I want to help translating Lichess
|
||||
|
||||
|
|
21
README.md
21
README.md
|
@ -1,5 +1,4 @@
|
|||
[lichess.org](https://lichess.org)
|
||||
==================================
|
||||
# [lichess.org](https://lichess.org)
|
||||
|
||||
[![Build server](https://github.com/ornicar/lila/workflows/Build%20server/badge.svg)](https://github.com/ornicar/lila/actions?query=workflow%3A%22Build+server%22)
|
||||
[![Build assets](https://github.com/ornicar/lila/workflows/Build%20assets/badge.svg)](https://github.com/ornicar/lila/actions?query=workflow%3A%22Build+assets%22)
|
||||
|
@ -8,7 +7,6 @@
|
|||
|
||||
<img src="https://raw.githubusercontent.com/ornicar/lila/master/public/images/home-bicolor.png" alt="Lichess homepage" title="Lichess comes with light and dark theme, this screenshot shows both." />
|
||||
|
||||
|
||||
Lila (li[chess in sca]la) is a free online chess game server focused on [realtime](https://lichess.org/games) gameplay and ease of use.
|
||||
|
||||
It features a [search engine](https://lichess.org/games/search),
|
||||
|
@ -43,8 +41,7 @@ See [lichess.org/source](https://lichess.org/source) for a list of repositories.
|
|||
[Join us on discord](https://discord.gg/hy5jqSs) or in the `#lichess` freenode IRC channel for more info.
|
||||
Use [GitHub issues](https://github.com/ornicar/lila/issues) for bug reports and feature requests.
|
||||
|
||||
Installation
|
||||
------------
|
||||
## Installation
|
||||
|
||||
```
|
||||
./lila # thin wrapper around sbt
|
||||
|
@ -53,21 +50,18 @@ run
|
|||
|
||||
The Wiki describes [how to setup a development environment](https://github.com/ornicar/lila/wiki/Lichess-Development-Onboarding).
|
||||
|
||||
HTTP API
|
||||
--------
|
||||
## HTTP API
|
||||
|
||||
Feel free to use the [Lichess API](https://lichess.org/api) in your applications and websites.
|
||||
|
||||
Credits
|
||||
-------
|
||||
## Credits
|
||||
|
||||
See the [contributors](https://github.com/ornicar/lila/graphs/contributors) on this repository and [lichess.org/thanks](https://lichess.org/thanks).
|
||||
|
||||
Supported browsers
|
||||
------------------
|
||||
## Supported browsers
|
||||
|
||||
| Name | Version | Notes |
|
||||
| ----------------- | ------- | ----- |
|
||||
| ----------------- | ------- | ------------------------------------------------- |
|
||||
| Chromium / Chrome | last 10 | Full support |
|
||||
| Firefox | 61+ | Full support (fastest local analysis since FF 79) |
|
||||
| Opera | 55+ | Reasonable support |
|
||||
|
@ -77,8 +71,7 @@ Supported browsers
|
|||
Older browsers (including any version of Internet Explorer) will not work.
|
||||
For your own sake, please upgrade. Security and performance, think about it!
|
||||
|
||||
License
|
||||
-------
|
||||
## License
|
||||
|
||||
Lila is licensed under the GNU Affero General Public License 3 or any later
|
||||
version at your choice with an exception for Highcharts. See COPYING for
|
||||
|
|
|
@ -1,36 +1,43 @@
|
|||
var result = db.game5.aggregate({
|
||||
var result = db.game5.aggregate(
|
||||
{
|
||||
$match: {
|
||||
ca: {
|
||||
$gt: ISODate("2013-02-14T14:06:03Z")
|
||||
$gt: ISODate('2013-02-14T14:06:03Z'),
|
||||
},
|
||||
s: {
|
||||
$gte: 30
|
||||
$gte: 30,
|
||||
},
|
||||
"us.0": {
|
||||
$exists: true
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$unwind: "$us"
|
||||
}, {
|
||||
'us.0': {
|
||||
$exists: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: '$us',
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
us: {
|
||||
$ne: ""
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$ne: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: "$us",
|
||||
_id: '$us',
|
||||
number: {
|
||||
$sum: 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$sum: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
number: -1
|
||||
number: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$limit: 10,
|
||||
}
|
||||
}, {
|
||||
$limit: 10
|
||||
});
|
||||
);
|
||||
|
||||
printjson(result);
|
||||
|
|
|
@ -4,70 +4,70 @@ var batchSize = 1000;
|
|||
var collection = db.analysis2;
|
||||
|
||||
var piotr = {
|
||||
'a': 'A1',
|
||||
'b': 'B1',
|
||||
'c': 'C1',
|
||||
'd': 'D1',
|
||||
'e': 'E1',
|
||||
'f': 'F1',
|
||||
'g': 'G1',
|
||||
'h': 'H1',
|
||||
'i': 'A2',
|
||||
'j': 'B2',
|
||||
'k': 'C2',
|
||||
'l': 'D2',
|
||||
'm': 'E2',
|
||||
'n': 'F2',
|
||||
'o': 'G2',
|
||||
'p': 'H2',
|
||||
'q': 'A3',
|
||||
'r': 'B3',
|
||||
's': 'C3',
|
||||
't': 'D3',
|
||||
'u': 'E3',
|
||||
'v': 'F3',
|
||||
'w': 'G3',
|
||||
'x': 'H3',
|
||||
'y': 'A4',
|
||||
'z': 'B4',
|
||||
'A': 'C4',
|
||||
'B': 'D4',
|
||||
'C': 'E4',
|
||||
'D': 'F4',
|
||||
'E': 'G4',
|
||||
'F': 'H4',
|
||||
'G': 'A5',
|
||||
'H': 'B5',
|
||||
'I': 'C5',
|
||||
'J': 'D5',
|
||||
'K': 'E5',
|
||||
'L': 'F5',
|
||||
'M': 'G5',
|
||||
'N': 'H5',
|
||||
'O': 'A6',
|
||||
'P': 'B6',
|
||||
'Q': 'C6',
|
||||
'R': 'D6',
|
||||
'S': 'E6',
|
||||
'T': 'F6',
|
||||
'U': 'G6',
|
||||
'V': 'H6',
|
||||
'W': 'A7',
|
||||
'X': 'B7',
|
||||
'Y': 'C7',
|
||||
'Z': 'D7',
|
||||
'0': 'E7',
|
||||
'1': 'F7',
|
||||
'2': 'G7',
|
||||
'3': 'H7',
|
||||
'4': 'A8',
|
||||
'5': 'B8',
|
||||
'6': 'C8',
|
||||
'7': 'D8',
|
||||
'8': 'E8',
|
||||
'9': 'F8',
|
||||
a: 'A1',
|
||||
b: 'B1',
|
||||
c: 'C1',
|
||||
d: 'D1',
|
||||
e: 'E1',
|
||||
f: 'F1',
|
||||
g: 'G1',
|
||||
h: 'H1',
|
||||
i: 'A2',
|
||||
j: 'B2',
|
||||
k: 'C2',
|
||||
l: 'D2',
|
||||
m: 'E2',
|
||||
n: 'F2',
|
||||
o: 'G2',
|
||||
p: 'H2',
|
||||
q: 'A3',
|
||||
r: 'B3',
|
||||
s: 'C3',
|
||||
t: 'D3',
|
||||
u: 'E3',
|
||||
v: 'F3',
|
||||
w: 'G3',
|
||||
x: 'H3',
|
||||
y: 'A4',
|
||||
z: 'B4',
|
||||
A: 'C4',
|
||||
B: 'D4',
|
||||
C: 'E4',
|
||||
D: 'F4',
|
||||
E: 'G4',
|
||||
F: 'H4',
|
||||
G: 'A5',
|
||||
H: 'B5',
|
||||
I: 'C5',
|
||||
J: 'D5',
|
||||
K: 'E5',
|
||||
L: 'F5',
|
||||
M: 'G5',
|
||||
N: 'H5',
|
||||
O: 'A6',
|
||||
P: 'B6',
|
||||
Q: 'C6',
|
||||
R: 'D6',
|
||||
S: 'E6',
|
||||
T: 'F6',
|
||||
U: 'G6',
|
||||
V: 'H6',
|
||||
W: 'A7',
|
||||
X: 'B7',
|
||||
Y: 'C7',
|
||||
Z: 'D7',
|
||||
0: 'E7',
|
||||
1: 'F7',
|
||||
2: 'G7',
|
||||
3: 'H7',
|
||||
4: 'A8',
|
||||
5: 'B8',
|
||||
6: 'C8',
|
||||
7: 'D8',
|
||||
8: 'E8',
|
||||
9: 'F8',
|
||||
'!': 'G8',
|
||||
'?': 'H8'
|
||||
'?': 'H8',
|
||||
};
|
||||
|
||||
function decodePiotr(pp) {
|
||||
|
@ -78,7 +78,7 @@ function decodeScore(pp) {
|
|||
return pp == '_' ? null : parseInt(pp);
|
||||
}
|
||||
|
||||
print("Migrating " + max + " analysis");
|
||||
print('Migrating ' + max + ' analysis');
|
||||
|
||||
collection.drop();
|
||||
|
||||
|
@ -98,7 +98,7 @@ gamesToMigrate.forEach(function(a) {
|
|||
best = decodePiotr(cur[1]),
|
||||
score = decodeScore(next[2]),
|
||||
mate = decodeScore(next[3]);
|
||||
data.push([score, mate == null ? null : (it % 2 == 1) ? mate : -mate].join(','));
|
||||
data.push([score, mate == null ? null : it % 2 == 1 ? mate : -mate].join(','));
|
||||
}
|
||||
a.data = data.join(';');
|
||||
delete a.encoded;
|
||||
|
@ -117,19 +117,19 @@ gamesToMigrate.forEach(function(a) {
|
|||
var dat2 = new Date().getTime() / 1000;
|
||||
var perSec = Math.round(batchSize / (dat2 - dat));
|
||||
dat = dat2;
|
||||
print((nb / 1000) + "k " + percent + "% " + perSec + "/s");
|
||||
print(nb / 1000 + 'k ' + percent + '% ' + perSec + '/s');
|
||||
}
|
||||
});
|
||||
|
||||
print("Building indexes");
|
||||
print('Building indexes');
|
||||
collection.ensureIndex({
|
||||
'done': 1
|
||||
done: 1,
|
||||
});
|
||||
collection.ensureIndex({
|
||||
'date': -1
|
||||
date: -1,
|
||||
});
|
||||
collection.ensureIndex({
|
||||
'uid': 1
|
||||
uid: 1,
|
||||
});
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -6,5 +6,5 @@ db.trophy.insert({
|
|||
_id: kind + '/' + user,
|
||||
user: user,
|
||||
kind: kind,
|
||||
date: new Date()
|
||||
date: new Date(),
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var limit = 50 * 1000;
|
||||
var coll = db.relation;
|
||||
var query = {
|
||||
_id: 'thibault/legendary22bcloud'
|
||||
_id: 'thibault/legendary22bcloud',
|
||||
};
|
||||
var expected = false;
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
db.clas_clas.ensureIndex({teachers:1,viewedAt:-1})
|
||||
db.clas_student.ensureIndex({clasId:1,userId:1})
|
||||
db.clas_student.ensureIndex({userId:1},{ partialFilterExpression: { managed: true } })
|
||||
db.clas_clas.ensureIndex({ teachers: 1, viewedAt: -1 });
|
||||
db.clas_student.ensureIndex({ clasId: 1, userId: 1 });
|
||||
db.clas_student.ensureIndex({ userId: 1 }, { partialFilterExpression: { managed: true } });
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
db.clas_clas.find({ createdAt: { $exists: 1 } }).forEach(clas => {
|
||||
db.clas_clas.update({_id: clas._id},{
|
||||
db.clas_clas.update(
|
||||
{ _id: clas._id },
|
||||
{
|
||||
$unset: { updatedAt: 1, createdAt: 1 },
|
||||
$set:{created:{by:clas.teachers[0],at:clas.createdAt}}
|
||||
});
|
||||
$set: { created: { by: clas.teachers[0], at: clas.createdAt } },
|
||||
}
|
||||
);
|
||||
});
|
||||
db.clas_student.find({ createdAt: { $exists: 1 } }).forEach(stu => {
|
||||
let teacher = db.clas_clas.findOne({ _id: stu.clasId }).teachers[0];
|
||||
db.clas_student.update({_id: stu._id},{
|
||||
db.clas_student.update(
|
||||
{ _id: stu._id },
|
||||
{
|
||||
$unset: { updatedAt: 1, createdAt: 1 },
|
||||
$set:{created:{by:teacher,at:stu.createdAt}}
|
||||
});
|
||||
$set: { created: { by: teacher, at: stu.createdAt } },
|
||||
}
|
||||
);
|
||||
});
|
||||
db.clas_student.find({ realName: { $exists: 0 } }).forEach(stu => {
|
||||
db.clas_student.update({_id: stu._id},{
|
||||
$set:{realName:stu.userId,notes:''}
|
||||
});
|
||||
db.clas_student.update(
|
||||
{ _id: stu._id },
|
||||
{
|
||||
$set: { realName: stu.userId, notes: '' },
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
db.user2.update({},{$unset:{
|
||||
db.user2.update(
|
||||
{},
|
||||
{
|
||||
$unset: {
|
||||
'settings.chat': 1,
|
||||
'settings.sound':1
|
||||
}}, {multi:1});
|
||||
'settings.sound': 1,
|
||||
},
|
||||
},
|
||||
{ multi: 1 }
|
||||
);
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
var d = new Date();
|
||||
d.setDate(d.getDate() - 1);
|
||||
|
||||
var ids = db.game4.find({t:{$lt:2},ca:{$lt:d}}, {_id:1}).limit(1000).toArray().map(function(g) {
|
||||
var ids = db.game4
|
||||
.find({ t: { $lt: 2 }, ca: { $lt: d } }, { _id: 1 })
|
||||
.limit(1000)
|
||||
.toArray()
|
||||
.map(function (g) {
|
||||
return g._id;
|
||||
});
|
||||
var nb = ids.length;
|
||||
|
||||
if (nb > 0) {
|
||||
print("First ID: " + ids[0]);
|
||||
print('First ID: ' + ids[0]);
|
||||
}
|
||||
|
||||
print("Remove " + nb + " games");
|
||||
print('Remove ' + nb + ' games');
|
||||
db.game4.remove({ _id: { $in: ids } });
|
||||
|
||||
print("Remove " + nb + " pgns");
|
||||
print('Remove ' + nb + ' pgns');
|
||||
db.pgn.remove({ _id: { $in: ids } });
|
||||
|
||||
print("Remove " + nb + " bookmarks");
|
||||
print('Remove ' + nb + ' bookmarks');
|
||||
db.bookmark.remove({ g: { $in: ids } });
|
||||
|
|
|
@ -10,4 +10,4 @@ db.game5.find({$or:[{p0:{}},{p1:{}}]}).forEach(g => {
|
|||
if (count % 10000 === 0) print(count);
|
||||
}
|
||||
});
|
||||
print("Done " + count);
|
||||
print('Done ' + count);
|
||||
|
|
|
@ -7,14 +7,15 @@ function toInt(obj) {
|
|||
db.config.find().forEach(function (config) {
|
||||
// printjson(config);
|
||||
['friend', 'hook', 'ai'].forEach(function (type) {
|
||||
['d', 'i', 'm', 't', 'tm', 'v', 'l'].forEach(toInt(config[type]))
|
||||
['d', 'i', 'm', 't', 'tm', 'v', 'l'].forEach(toInt(config[type]));
|
||||
});
|
||||
var filter = config.filter;
|
||||
['m', 's', 'v'].forEach(function (prop) {
|
||||
if (typeof filter[prop] != 'undefined') filter[prop] = filter[prop].map(function(n) {
|
||||
if (typeof filter[prop] != 'undefined')
|
||||
filter[prop] = filter[prop].map(function (n) {
|
||||
return NumberInt(n);
|
||||
});
|
||||
});
|
||||
// printjson(config);
|
||||
db.config.update({"_id": config._id}, config);
|
||||
db.config.update({ _id: config._id }, config);
|
||||
});
|
||||
|
|
|
@ -8,11 +8,14 @@
|
|||
sets[type + '.d'] = NumberInt(2);
|
||||
unsets[type + '.k'] = true;
|
||||
});
|
||||
coll.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
coll.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$set: sets,
|
||||
$unset: unsets
|
||||
});
|
||||
$unset: unsets,
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,126 +1,126 @@
|
|||
db.trophyKind.drop();
|
||||
db.trophyKind.insert({
|
||||
_id: "zugMiracle",
|
||||
name: "Zug miracle",
|
||||
url: "//lichess.org/faq#trophies",
|
||||
_id: 'zugMiracle',
|
||||
name: 'Zug miracle',
|
||||
url: '//lichess.org/faq#trophies',
|
||||
order: NumberInt(1),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "wayOfBerserk",
|
||||
name: "The way of Berserk",
|
||||
icon: "`",
|
||||
url: "//lichess.org/faq#trophies",
|
||||
klass: "fire-trophy",
|
||||
_id: 'wayOfBerserk',
|
||||
name: 'The way of Berserk',
|
||||
icon: '`',
|
||||
url: '//lichess.org/faq#trophies',
|
||||
klass: 'fire-trophy',
|
||||
order: NumberInt(2),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "marathonWinner",
|
||||
name: "Marathon Winner",
|
||||
icon: "\\",
|
||||
klass: "fire-trophy",
|
||||
_id: 'marathonWinner',
|
||||
name: 'Marathon Winner',
|
||||
icon: '\\',
|
||||
klass: 'fire-trophy',
|
||||
order: NumberInt(3),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "marathonTopTen",
|
||||
name: "Marathon Top 10",
|
||||
icon: "\\",
|
||||
klass: "fire-trophy",
|
||||
_id: 'marathonTopTen',
|
||||
name: 'Marathon Top 10',
|
||||
icon: '\\',
|
||||
klass: 'fire-trophy',
|
||||
order: NumberInt(4),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "marathonTopFifty",
|
||||
name: "Marathon Top 50",
|
||||
icon: "\\",
|
||||
klass: "fire-trophy",
|
||||
_id: 'marathonTopFifty',
|
||||
name: 'Marathon Top 50',
|
||||
icon: '\\',
|
||||
klass: 'fire-trophy',
|
||||
order: NumberInt(5),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "marathonTopHundred",
|
||||
name: "Marathon Top 100",
|
||||
icon: "\\",
|
||||
klass: "fire-trophy",
|
||||
_id: 'marathonTopHundred',
|
||||
name: 'Marathon Top 100',
|
||||
icon: '\\',
|
||||
klass: 'fire-trophy',
|
||||
order: NumberInt(6),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "marathonSurvivor",
|
||||
name: "Marathon #1 survivor",
|
||||
icon: ",",
|
||||
url: "//lichess.org/blog/VXF45yYAAPQgLH4d/chess-marathon-1",
|
||||
klass: "fire-trophy",
|
||||
_id: 'marathonSurvivor',
|
||||
name: 'Marathon #1 survivor',
|
||||
icon: ',',
|
||||
url: '//lichess.org/blog/VXF45yYAAPQgLH4d/chess-marathon-1',
|
||||
klass: 'fire-trophy',
|
||||
order: NumberInt(7),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "developer",
|
||||
name: "Lichess developer",
|
||||
icon: "\ue000",
|
||||
url: "https://github.com/ornicar/lila/graphs/contributors",
|
||||
klass: "icon3d",
|
||||
_id: 'developer',
|
||||
name: 'Lichess developer',
|
||||
icon: '\ue000',
|
||||
url: 'https://github.com/ornicar/lila/graphs/contributors',
|
||||
klass: 'icon3d',
|
||||
order: NumberInt(100),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "moderator",
|
||||
name: "Lichess moderator",
|
||||
icon: "\ue002",
|
||||
url: "//lichess.org/report",
|
||||
klass: "icon3d",
|
||||
_id: 'moderator',
|
||||
name: 'Lichess moderator',
|
||||
icon: '\ue002',
|
||||
url: '//lichess.org/report',
|
||||
klass: 'icon3d',
|
||||
order: NumberInt(101),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "verified",
|
||||
name: "Verified account",
|
||||
icon: "E",
|
||||
klass: "icon3d",
|
||||
_id: 'verified',
|
||||
name: 'Verified account',
|
||||
icon: 'E',
|
||||
klass: 'icon3d',
|
||||
order: NumberInt(102),
|
||||
withCustomImage: false
|
||||
withCustomImage: false,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "zhwc17",
|
||||
name: "Crazyhouse champion 2017",
|
||||
url: "//lichess.org/blog/WMnMzSEAAMgA3oAW/crazyhouse-world-championship-the-candidates",
|
||||
_id: 'zhwc17',
|
||||
name: 'Crazyhouse champion 2017',
|
||||
url: '//lichess.org/blog/WMnMzSEAAMgA3oAW/crazyhouse-world-championship-the-candidates',
|
||||
order: NumberInt(1),
|
||||
withCustomImage: true
|
||||
withCustomImage: true,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "zhwc18",
|
||||
name: "Crazyhouse champion 2018",
|
||||
url: "//lichess.org/forum/team-crazyhouse-world-championship/opperwezen-the-2nd-cwc",
|
||||
_id: 'zhwc18',
|
||||
name: 'Crazyhouse champion 2018',
|
||||
url: '//lichess.org/forum/team-crazyhouse-world-championship/opperwezen-the-2nd-cwc',
|
||||
order: NumberInt(1),
|
||||
withCustomImage: true
|
||||
withCustomImage: true,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "atomicwc16",
|
||||
name: "Atomic World Champion 2016",
|
||||
url: "//lichess.org/forum/team-atomic-wc/championship-final",
|
||||
_id: 'atomicwc16',
|
||||
name: 'Atomic World Champion 2016',
|
||||
url: '//lichess.org/forum/team-atomic-wc/championship-final',
|
||||
order: NumberInt(1),
|
||||
withCustomImage: true
|
||||
withCustomImage: true,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "atomicwc17",
|
||||
name: "Atomic World Champion 2017",
|
||||
url: "//lichess.org/forum/team-atomic-wc/awc-2017-its-final-time",
|
||||
_id: 'atomicwc17',
|
||||
name: 'Atomic World Champion 2017',
|
||||
url: '//lichess.org/forum/team-atomic-wc/awc-2017-its-final-time',
|
||||
order: NumberInt(1),
|
||||
withCustomImage: true
|
||||
withCustomImage: true,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "atomicwc18",
|
||||
name: "Atomic World Champion 2018",
|
||||
url: "//lichess.org/forum/team-atomic-wc/announcement-awc-2018",
|
||||
_id: 'atomicwc18',
|
||||
name: 'Atomic World Champion 2018',
|
||||
url: '//lichess.org/forum/team-atomic-wc/announcement-awc-2018',
|
||||
order: NumberInt(1),
|
||||
withCustomImage: true
|
||||
withCustomImage: true,
|
||||
});
|
||||
db.trophyKind.insert({
|
||||
_id: "acwc18",
|
||||
name: "Antichess World Champion 2018",
|
||||
url: "//lichess.org/forum/team-antichess-wc/congratulations-to-our-new-antichess-world-champion",
|
||||
_id: 'acwc18',
|
||||
name: 'Antichess World Champion 2018',
|
||||
url: '//lichess.org/forum/team-antichess-wc/congratulations-to-our-new-antichess-world-champion',
|
||||
order: NumberInt(1),
|
||||
withCustomImage: true
|
||||
withCustomImage: true,
|
||||
});
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
var user = 'colin_ni';
|
||||
db.f_post.update({userId:user},{$set:{text:'',erasedAt:new Date()}},{multi:1})
|
||||
db.f_post.update({ userId: user }, { $set: { text: '', erasedAt: new Date() } }, { multi: 1 });
|
||||
|
|
|
@ -2,14 +2,19 @@ var gamesToMigrate = db.game4.find({}, {uids: true, 'p.uid': true});
|
|||
var max = gamesToMigrate.count();
|
||||
var batchSize = 50000;
|
||||
|
||||
print("Migrating " + max + " games");
|
||||
print('Migrating ' + max + ' games');
|
||||
|
||||
var i, j = 0, t, timeStrings, times, it=0;
|
||||
var i,
|
||||
j = 0,
|
||||
t,
|
||||
timeStrings,
|
||||
times,
|
||||
it = 0;
|
||||
var dat = new Date().getTime() / 1000;
|
||||
|
||||
gamesToMigrate.forEach(function (game) {
|
||||
|
||||
var prev = '', uids = [];
|
||||
var prev = '',
|
||||
uids = [];
|
||||
game.p.forEach(function (p) {
|
||||
if (p.uid && p.uid != prev) {
|
||||
uids.push(p.uid);
|
||||
|
@ -20,7 +25,7 @@ gamesToMigrate.forEach(function(game) {
|
|||
var gameSris = game.uids || [];
|
||||
if (gameSris.length != uids.length) {
|
||||
++j;
|
||||
db.game4.update({_id: game['_id']}, {$set: {'uids': uids}});
|
||||
db.game4.update({ _id: game['_id'] }, { $set: { uids: uids } });
|
||||
}
|
||||
|
||||
++it;
|
||||
|
@ -29,7 +34,7 @@ gamesToMigrate.forEach(function(game) {
|
|||
var dat2 = new Date().getTime() / 1000;
|
||||
var perSec = Math.round(batchSize / (dat2 - dat));
|
||||
dat = dat2;
|
||||
print((it / 1000) + "k " + percent + "% " + perSec + "/s - " + j + " updated");
|
||||
print(it / 1000 + 'k ' + percent + '% ' + perSec + '/s - ' + j + ' updated');
|
||||
j = 0;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,27 +3,30 @@ var inOneMonth = new Date(ISODate().getTime() + 1000 * 60 * 60 * 24 * 31);
|
|||
|
||||
db.plan_patron.remove({});
|
||||
db.plan_charge.remove({});
|
||||
db.user4.update({
|
||||
db.user4.update(
|
||||
{
|
||||
plan: {
|
||||
$exists: true
|
||||
}
|
||||
}, {
|
||||
$exists: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unset: {
|
||||
plan: true
|
||||
plan: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
multi: true,
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
);
|
||||
|
||||
var userIds = [];
|
||||
|
||||
function donationToPatron(donation) {
|
||||
|
||||
var charge = {
|
||||
_id: donation._id,
|
||||
date: donation.date,
|
||||
cents: donation.gross,
|
||||
payPal: {}
|
||||
payPal: {},
|
||||
};
|
||||
if (donation.userId) charge.userId = donation.userId;
|
||||
if (donation.payPalTnx) charge.payPal.tnxId = donation.payPalTnx;
|
||||
|
@ -38,37 +41,43 @@ function donationToPatron(donation) {
|
|||
var patron = {
|
||||
_id: donation.userId,
|
||||
payPal: {
|
||||
lastCharge: donation.date
|
||||
lastCharge: donation.date,
|
||||
},
|
||||
lastLevelUp: now,
|
||||
expiresAt: inOneMonth
|
||||
}
|
||||
expiresAt: inOneMonth,
|
||||
};
|
||||
if (donation.payPalSub) patron.payPal.subId = donation.payPalSub;
|
||||
if (donation.email) patron.payPal.email = donation.email;
|
||||
db.plan_patron.insert(patron);
|
||||
db.user4.update({
|
||||
_id: donation.userId
|
||||
}, {
|
||||
db.user4.update(
|
||||
{
|
||||
_id: donation.userId,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
plan: {
|
||||
active: true,
|
||||
months: NumberInt(1),
|
||||
since: donation.date
|
||||
since: donation.date,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
db.donation.find({
|
||||
db.donation
|
||||
.find({
|
||||
userId: {
|
||||
'$exists': true
|
||||
}
|
||||
}).sort({
|
||||
date: -1
|
||||
}).forEach(donationToPatron);
|
||||
$exists: true,
|
||||
},
|
||||
})
|
||||
.sort({
|
||||
date: -1,
|
||||
})
|
||||
.forEach(donationToPatron);
|
||||
|
||||
donationToPatron({
|
||||
userId: 'thibault',
|
||||
date: new Date(ISODate().getTime() - 1000 * 60 * 60 * 24 * 31 * 3),
|
||||
email: 'lichess.contact@gmail.com'
|
||||
email: 'lichess.contact@gmail.com',
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ const colls = ['tournament2'];
|
|||
colls.forEach(function (coll) {
|
||||
indexes = db[coll].getIndexes();
|
||||
if (indexes && indexes.length > 0) {
|
||||
print("//Indexes for " + coll + ":");
|
||||
print('//Indexes for ' + coll + ':');
|
||||
}
|
||||
indexes.forEach(function (index) {
|
||||
var options = {};
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
function gmailNormalize(email) {
|
||||
let [name, domain] = email.toLowerCase().split('@');
|
||||
[name, ] = name.split('+');
|
||||
[name] = name.split('+');
|
||||
return name.replace(/\./g, '') + '@' + domain;
|
||||
}
|
||||
|
||||
db.user4.find({email: /[^+.]+[+.].*@(protonmail\.com|protonmail\.ch|pm\.me|gmail\.com|googlemail\.com)$/i}).forEach(user => {
|
||||
db.user4
|
||||
.find({ email: /[^+.]+[+.].*@(protonmail\.com|protonmail\.ch|pm\.me|gmail\.com|googlemail\.com)$/i })
|
||||
.forEach(user => {
|
||||
const normalized = gmailNormalize(user.email);
|
||||
const verbatim = user.verbatimEmail || user.email;
|
||||
print(user.username, ': ', verbatim, '->', normalized);
|
||||
|
||||
db.user4.update({
|
||||
_id: user._id
|
||||
}, {
|
||||
db.user4.update(
|
||||
{
|
||||
_id: user._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
email: normalized,
|
||||
verbatimEmail: verbatim
|
||||
verbatimEmail: verbatim,
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,29 +1,37 @@
|
|||
db.f_categ.find({
|
||||
db.f_categ
|
||||
.find({
|
||||
pos: {
|
||||
$type: 1
|
||||
}
|
||||
}).forEach(function(o) {
|
||||
$type: 1,
|
||||
},
|
||||
})
|
||||
.forEach(function (o) {
|
||||
print(o.name);
|
||||
db.f_categ.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
db.f_categ.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$unset: {
|
||||
pos: 1,
|
||||
nbTopics: 1,
|
||||
nbPosts: 1,
|
||||
nbTopicsTroll: 1,
|
||||
nbPostsTroll: 1
|
||||
nbPostsTroll: 1,
|
||||
},
|
||||
}
|
||||
});
|
||||
db.f_categ.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
);
|
||||
db.f_categ.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
pos: NumberInt(o.pos),
|
||||
nbTopics: NumberInt(o.nbTopics),
|
||||
nbPosts: NumberInt(o.nbPosts),
|
||||
nbTopicsTroll: NumberInt(o.nbTopicsTroll),
|
||||
nbPostsTroll: NumberInt(o.nbPostsTroll)
|
||||
nbPostsTroll: NumberInt(o.nbPostsTroll),
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -9,7 +9,8 @@ function daysAgo(days) {
|
|||
}
|
||||
|
||||
for (var i = daysBack; i >= 0; i--) {
|
||||
var from = daysAgo(i + 1), to = daysAgo(i);
|
||||
var from = daysAgo(i + 1),
|
||||
to = daysAgo(i);
|
||||
var games = db.game5.count({ ca: { $gte: from, $lt: to } });
|
||||
print(i + ' days ago, from ' + from + ' to ' + to + ' -> ' + games + ' games');
|
||||
}
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
const coll = db.game_search;
|
||||
|
||||
const players = ["penguingim1", "aladdin65", "aleksey472", "azuaga", "benpig", "blackboarder", "bockosrb555", "bogdan_low_player", "charlytb", "chchbbuur", "chessexplained", "cmcookiemonster", "crptone", "cselhu3", "darkzam", "dmitri31", "dorado99", "ericrosen", "fast-tsunami", "flaneur" ];
|
||||
const players = [
|
||||
'penguingim1',
|
||||
'aladdin65',
|
||||
'aleksey472',
|
||||
'azuaga',
|
||||
'benpig',
|
||||
'blackboarder',
|
||||
'bockosrb555',
|
||||
'bogdan_low_player',
|
||||
'charlytb',
|
||||
'chchbbuur',
|
||||
'chessexplained',
|
||||
'cmcookiemonster',
|
||||
'crptone',
|
||||
'cselhu3',
|
||||
'darkzam',
|
||||
'dmitri31',
|
||||
'dorado99',
|
||||
'ericrosen',
|
||||
'fast-tsunami',
|
||||
'flaneur',
|
||||
];
|
||||
const sources = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||
const variants = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||
const results = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||
|
@ -34,11 +55,11 @@ for (let i = 0; i < nbGames; i++) {
|
|||
minutes: NumberInt(30 + intRandom(3600 * 3)),
|
||||
clock: {
|
||||
init: NumberInt(0 + intRandom(10800)),
|
||||
inc: NumberInt(0 + intRandom(180))
|
||||
inc: NumberInt(0 + intRandom(180)),
|
||||
},
|
||||
result: anyOf(results),
|
||||
date: new Date(Date.now() - intRandom(118719488)),
|
||||
analysed: !!intRandom(2)
|
||||
analysed: !!intRandom(2),
|
||||
});
|
||||
if (i % 1000 == 0) print(`${i} / ${nbGames}`);
|
||||
}
|
||||
|
@ -58,25 +79,28 @@ const indexes = [
|
|||
{ 'clock.inc': 1 },
|
||||
{ result: 1 },
|
||||
{ date: 1 },
|
||||
{analysed: 1}
|
||||
{ analysed: 1 },
|
||||
];
|
||||
|
||||
print("Adding indexes");
|
||||
print('Adding indexes');
|
||||
indexes.forEach(index => {
|
||||
printjson(index);
|
||||
db.game_search.createIndex(index);
|
||||
});
|
||||
|
||||
print("Searching");
|
||||
db.game_search.find({
|
||||
print('Searching');
|
||||
db.game_search
|
||||
.find({
|
||||
avgRating: { $gt: 1000 },
|
||||
turns: { $lt: 250 },
|
||||
'clock.init': { $gt: 1 },
|
||||
minutes: { $gt: 2, $lt: 150 },
|
||||
}).sort({
|
||||
date: -1
|
||||
}).limit(20).explain('executionStats');
|
||||
|
||||
})
|
||||
.sort({
|
||||
date: -1,
|
||||
})
|
||||
.limit(20)
|
||||
.explain('executionStats');
|
||||
|
||||
/*
|
||||
"executionStats": {
|
||||
|
|
|
@ -4,7 +4,7 @@ var batchSize = 10000;
|
|||
var collection = db.game3;
|
||||
var pgnCollection = db.pgn;
|
||||
|
||||
print("Migrating " + max + " games");
|
||||
print('Migrating ' + max + ' games');
|
||||
|
||||
collection.drop();
|
||||
pgnCollection.drop();
|
||||
|
@ -23,7 +23,7 @@ function map(arr, key, f) {
|
|||
}
|
||||
|
||||
function clean(arr, key) {
|
||||
if (typeof arr[key] !== 'undefined' && (arr[key] === null || arr[key] === "")) {
|
||||
if (typeof arr[key] !== 'undefined' && (arr[key] === null || arr[key] === '')) {
|
||||
delete arr[key];
|
||||
}
|
||||
}
|
||||
|
@ -39,9 +39,13 @@ function cleanOrRename(arr, from, to) {
|
|||
rename(arr, from, to);
|
||||
}
|
||||
|
||||
function removeSpace(str) { return str.replace(/ /g, ''); }
|
||||
function removeSpace(str) {
|
||||
return str.replace(/ /g, '');
|
||||
}
|
||||
|
||||
function finishedOrAborted(game) { return game.status >= 25; }
|
||||
function finishedOrAborted(game) {
|
||||
return game.status >= 25;
|
||||
}
|
||||
|
||||
var c, z, pgn;
|
||||
var it = 0;
|
||||
|
@ -83,7 +87,7 @@ gamesToMigrate.forEach(function(g) {
|
|||
cleanOrRename(g, 'positionHashes', 'ph');
|
||||
}
|
||||
cleanOrRename(g, 'clock', 'c');
|
||||
if (c = g.c) {
|
||||
if ((c = g.c)) {
|
||||
if (finishedOrAborted(g)) {
|
||||
delete c.timer;
|
||||
} else {
|
||||
|
@ -113,7 +117,7 @@ gamesToMigrate.forEach(function(g) {
|
|||
pgn = g.pgn;
|
||||
delete g.pgn;
|
||||
collection.insert(g);
|
||||
if (pgn !== null && pgn !== "") {
|
||||
if (pgn !== null && pgn !== '') {
|
||||
pgnCollection.insert({ _id: g._id, p: pgn });
|
||||
}
|
||||
++it;
|
||||
|
@ -122,11 +126,11 @@ gamesToMigrate.forEach(function(g) {
|
|||
var dat2 = new Date().getTime() / 1000;
|
||||
var perSec = Math.round(batchSize / (dat2 - dat));
|
||||
dat = dat2;
|
||||
print((it / 1000) + "k " + percent + "% " + perSec + "/s");
|
||||
print(it / 1000 + 'k ' + percent + '% ' + perSec + '/s');
|
||||
}
|
||||
});
|
||||
|
||||
print("Building indexes");
|
||||
print('Building indexes');
|
||||
collection.ensureIndex({ s: 1 });
|
||||
collection.ensureIndex({ uids: 1 }, { sparse: 1 });
|
||||
collection.ensureIndex({ wid: 1 }, { sparse: 1 });
|
||||
|
@ -134,4 +138,4 @@ collection.ensureIndex({ca: -1});
|
|||
collection.ensureIndex({ uids: 1, ca: -1 });
|
||||
collection.ensureIndex({ bm: 1 }, { sparse: 1 });
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -3,32 +3,36 @@ var max = gamesToMigrate.count();
|
|||
var batchSize = 10000;
|
||||
var collection = db.game4;
|
||||
|
||||
print("Migrating " + max + " games");
|
||||
print('Migrating ' + max + ' games');
|
||||
|
||||
collection.drop();
|
||||
|
||||
var timechars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
var timechars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
var timecharsLength = timechars.length;
|
||||
var lastchar = timechars[timecharsLength - 1];
|
||||
|
||||
var i, t, timeStrings, times, it=0;
|
||||
var i,
|
||||
t,
|
||||
timeStrings,
|
||||
times,
|
||||
it = 0;
|
||||
var dat = new Date().getTime() / 1000;
|
||||
gamesToMigrate.forEach(function (g) {
|
||||
g.p.forEach(function (p) {
|
||||
if (typeof p.mts != "undefined") {
|
||||
if (typeof p.mts != 'undefined') {
|
||||
if (p.mts === null || p.mts.length === 0) {
|
||||
delete p.mts;
|
||||
} else {
|
||||
try {
|
||||
times = "";
|
||||
times = '';
|
||||
timeStrings = p.mts.split(' ');
|
||||
for (i in timeStrings) {
|
||||
t = parseInt(timeStrings[i]);
|
||||
times += (t < timecharsLength) ? timechars[t] : lastchar;
|
||||
times += t < timecharsLength ? timechars[t] : lastchar;
|
||||
}
|
||||
p.mts = times;
|
||||
} catch (e) {
|
||||
print(g._id + " " + e);
|
||||
print(g._id + ' ' + e);
|
||||
delete p.mts;
|
||||
}
|
||||
}
|
||||
|
@ -41,11 +45,11 @@ gamesToMigrate.forEach(function(g) {
|
|||
var dat2 = new Date().getTime() / 1000;
|
||||
var perSec = Math.round(batchSize / (dat2 - dat));
|
||||
dat = dat2;
|
||||
print((it / 1000) + "k " + percent + "% " + perSec + "/s");
|
||||
print(it / 1000 + 'k ' + percent + '% ' + perSec + '/s');
|
||||
}
|
||||
});
|
||||
|
||||
print("Building indexes");
|
||||
print('Building indexes');
|
||||
collection.ensureIndex({ s: 1 });
|
||||
collection.ensureIndex({ uids: 1 }, { sparse: 1 });
|
||||
collection.ensureIndex({ wid: 1 }, { sparse: 1 });
|
||||
|
@ -53,4 +57,4 @@ collection.ensureIndex({ca: -1});
|
|||
collection.ensureIndex({ uids: 1, ca: -1 });
|
||||
collection.ensureIndex({ bm: 1 }, { sparse: 1 });
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
var userIds = ['sasha'].map(u => u.toLowerCase());
|
||||
var perfTypes = ['bullet', 'blitz', 'rapid', 'classical'];
|
||||
var perf = {
|
||||
"gl": {
|
||||
"r": 2700,
|
||||
"d": 150,
|
||||
"v": 0.06
|
||||
gl: {
|
||||
r: 2700,
|
||||
d: 150,
|
||||
v: 0.06,
|
||||
},
|
||||
"nb": NumberInt(0),
|
||||
"re": [ ]
|
||||
nb: NumberInt(0),
|
||||
re: [],
|
||||
};
|
||||
var updateTournaments = false;
|
||||
|
||||
|
@ -17,8 +17,10 @@ userIds.forEach(id => {
|
|||
if (user && (!user.perfs[pt] || !user.perfs[pt].nb))
|
||||
db.user4.update({ _id: id }, { $set: { ['perfs.' + pt]: perf } });
|
||||
});
|
||||
if (updateTournaments) db.tournament_player.update(
|
||||
if (updateTournaments)
|
||||
db.tournament_player.update(
|
||||
{ uid: id, r: 1500, m: 1500 },
|
||||
{ $set: { r: NumberInt(perf.gl.r), m: NumberInt(perf.gl.r) } },
|
||||
{multi:1});
|
||||
{ multi: 1 }
|
||||
);
|
||||
});
|
||||
|
|
|
@ -3,9 +3,10 @@ var max = historyToMigrate.count();
|
|||
var batchSize = 1000;
|
||||
var collection = db.history;
|
||||
var games = db.game4;
|
||||
var dat = new Date().getTime() / 1000, it = 0;
|
||||
var dat = new Date().getTime() / 1000,
|
||||
it = 0;
|
||||
|
||||
print("Migrating " + max + " user histories");
|
||||
print('Migrating ' + max + ' user histories');
|
||||
|
||||
collection.drop();
|
||||
|
||||
|
@ -16,7 +17,7 @@ historyToMigrate.forEach(function(h) {
|
|||
var e = h.entries[ts];
|
||||
var e2 = [parseInt(ts), parseInt(e.e)];
|
||||
if (e.g) {
|
||||
game = games.findOne({_id: e.g},{"p.elo": true, "p.uid": true});
|
||||
game = games.findOne({ _id: e.g }, { 'p.elo': true, 'p.uid': true });
|
||||
if (game) {
|
||||
if (game.p[0].uid != h._id) e2.push(game.p[0].elo);
|
||||
else e2.push(game.p[1].elo);
|
||||
|
@ -31,7 +32,6 @@ historyToMigrate.forEach(function(h) {
|
|||
var dat2 = new Date().getTime() / 1000;
|
||||
var perSec = Math.round(batchSize / (dat2 - dat));
|
||||
dat = dat2;
|
||||
print((it / 1000) + "k " + percent + "% " + perSec + "/s");
|
||||
print(it / 1000 + 'k ' + percent + '% ' + perSec + '/s');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
var batchSize = 20000;
|
||||
var collection = db.history;
|
||||
var games = db.game4.find(
|
||||
{'p.ed':{$exists:true}},
|
||||
{'p.elo': true, 'p.ed': true, 'p.uid': true, 'ca': true}
|
||||
).sort({ca: 1});
|
||||
var dat = new Date().getTime() / 1000, it = 0;
|
||||
var games = db.game4
|
||||
.find({ 'p.ed': { $exists: true } }, { 'p.elo': true, 'p.ed': true, 'p.uid': true, ca: true })
|
||||
.sort({ ca: 1 });
|
||||
var dat = new Date().getTime() / 1000,
|
||||
it = 0;
|
||||
|
||||
print("Counting games...");
|
||||
print('Counting games...');
|
||||
var max = games.count();
|
||||
print("Migrating " + max + " games to user histories");
|
||||
print('Migrating ' + max + ' games to user histories');
|
||||
|
||||
collection.drop();
|
||||
|
||||
|
@ -22,22 +22,19 @@ var cache = {};
|
|||
games.forEach(function (game) {
|
||||
for (pi in game.p) {
|
||||
try {
|
||||
var p = game.p[pi], op = game.p[1 - pi];
|
||||
var entry = [
|
||||
parseInt(game.ca.getTime() / 1000),
|
||||
parseInt(p.elo + p.ed),
|
||||
parseInt(op.elo)
|
||||
];
|
||||
if(typeof cache[p.uid] == "undefined") cache[p.uid] = [entry];
|
||||
var p = game.p[pi],
|
||||
op = game.p[1 - pi];
|
||||
var entry = [parseInt(game.ca.getTime() / 1000), parseInt(p.elo + p.ed), parseInt(op.elo)];
|
||||
if (typeof cache[p.uid] == 'undefined') cache[p.uid] = [entry];
|
||||
else cache[p.uid].push(entry);
|
||||
} catch (e) {
|
||||
print("game " + game._id + " => " + e);
|
||||
print('game ' + game._id + ' => ' + e);
|
||||
}
|
||||
}
|
||||
++it;
|
||||
if (it % batchSize == 0) {
|
||||
if (it % (batchSize * 7) == 0) {
|
||||
print("FLUSH");
|
||||
print('FLUSH');
|
||||
flush(cache);
|
||||
cache = {};
|
||||
}
|
||||
|
@ -45,8 +42,8 @@ games.forEach(function(game) {
|
|||
var dat2 = new Date().getTime() / 1000;
|
||||
var perSec = Math.round(batchSize / (dat2 - dat));
|
||||
dat = dat2;
|
||||
print((it / 1000) + "k " + percent + "% " + perSec + "/s");
|
||||
print(it / 1000 + 'k ' + percent + '% ' + perSec + '/s');
|
||||
}
|
||||
});
|
||||
print("FLUSH");
|
||||
print('FLUSH');
|
||||
flush(cache);
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
[db.config, db.config_anon].forEach(function (coll) {
|
||||
coll.find().forEach(function (o) {
|
||||
if (o.filter && o.filter.v && o.filter.v.length > 1) {
|
||||
coll.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
coll.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$push: {
|
||||
'filter.v': NumberInt(8)
|
||||
'filter.v': NumberInt(8),
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,13 +4,13 @@ db.trophy.insert({
|
|||
_id: 'zugMiracle',
|
||||
kind: 'zugMiracle',
|
||||
user: 'zugaddict',
|
||||
date: new Date()
|
||||
date: new Date(),
|
||||
});
|
||||
db.trophy.insert({
|
||||
_id: 'wayOfBerserk',
|
||||
kind: 'wayOfBerserk',
|
||||
user: 'hiimgosu',
|
||||
date: new Date()
|
||||
date: new Date(),
|
||||
});
|
||||
// db.trophy.insert({
|
||||
// _id: 'marathon1',
|
||||
|
|
|
@ -8,14 +8,20 @@ t._id = id;
|
|||
t.name = '2017 Winter Marathon';
|
||||
t.clock = {
|
||||
limit: NumberInt(5 * 60),
|
||||
increment: NumberInt(3)
|
||||
increment: NumberInt(3),
|
||||
};
|
||||
t.schedule.speed = 'blitz';
|
||||
t.startsAt = ISODate('2017-12-28');
|
||||
t.spotlight.description =
|
||||
"Let's make this the biggest chess tournament in history. " +
|
||||
"24h of " + (t.clock.limit / 60) + "+" + t.clock.increment + " " + t.schedule.speed + " chess: " +
|
||||
"top 100 players get a unique trophy!";
|
||||
'24h of ' +
|
||||
t.clock.limit / 60 +
|
||||
'+' +
|
||||
t.clock.increment +
|
||||
' ' +
|
||||
t.schedule.speed +
|
||||
' chess: ' +
|
||||
'top 100 players get a unique trophy!';
|
||||
|
||||
// initialize values
|
||||
t.status = NumberInt(10);
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
var users = [
|
||||
'blitzstream-twitch',
|
||||
'legend',
|
||||
'admirala',
|
||||
'hellball'
|
||||
];
|
||||
var users = ['blitzstream-twitch', 'legend', 'admirala', 'hellball'];
|
||||
|
||||
for (var i in users) {
|
||||
var kind = i == 0 ? 'marathonWinner' : 'marathonTopTen';
|
||||
|
@ -12,6 +7,6 @@ for (var i in users) {
|
|||
_id: kind + '/' + user,
|
||||
user: user,
|
||||
kind: kind,
|
||||
date: new Date()
|
||||
date: new Date(),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
var sender = 'lichess';
|
||||
var threadName = "Lichess meetup in London, November 24th";
|
||||
var threadName = 'Lichess meetup in London, November 24th';
|
||||
|
||||
var sent = 0;
|
||||
|
||||
db.user4.find({
|
||||
db.user4
|
||||
.find({
|
||||
'profile.location': 'montreal',
|
||||
enabled: true,
|
||||
seenAt:{$gt:new Date(Date.now() - 1000 * 3600 * 24 * 30)}
|
||||
}).forEach(user => {
|
||||
if (db.notify.count({
|
||||
seenAt: { $gt: new Date(Date.now() - 1000 * 3600 * 24 * 30) },
|
||||
})
|
||||
.forEach(user => {
|
||||
if (
|
||||
db.notify.count({
|
||||
notifies: user._id,
|
||||
'content.type': 'privateMessage',
|
||||
'content.thread.name': threadName
|
||||
})) return;
|
||||
'content.thread.name': threadName,
|
||||
})
|
||||
)
|
||||
return;
|
||||
var threadId = Math.random().toString(36).substring(2, 10);
|
||||
db.notify.insert({
|
||||
_id: Math.random().toString(36).substring(2, 10),
|
||||
|
@ -22,35 +27,33 @@ db.user4.find({
|
|||
senderId: sender,
|
||||
thread: {
|
||||
id: threadId,
|
||||
name: threadName
|
||||
name: threadName,
|
||||
},
|
||||
text: threadName
|
||||
text: threadName,
|
||||
},
|
||||
read: false,
|
||||
createdAt: new Date()
|
||||
createdAt: new Date(),
|
||||
});
|
||||
print(user.username);
|
||||
db.m_thread.insert({
|
||||
_id: threadId,
|
||||
"name": threadName,
|
||||
"createdAt": new Date(),
|
||||
"updatedAt": new Date(),
|
||||
"posts": [
|
||||
name: threadName,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
posts: [
|
||||
{
|
||||
"id": Math.random().toString(36).substring(2, 10),
|
||||
"text": "You are most welcome to join us!\n\nhttps://lichess.org/blog/W-nQzxYAAC8AaUUo/lichess-london-meetup-on-the-24th-november\n\nYou received this message because you connected from the UK, Ireland, France or Belgium.",
|
||||
"isByCreator": true,
|
||||
"isRead": false,
|
||||
"createdAt": new Date()
|
||||
}
|
||||
id: Math.random().toString(36).substring(2, 10),
|
||||
text:
|
||||
'You are most welcome to join us!\n\nhttps://lichess.org/blog/W-nQzxYAAC8AaUUo/lichess-london-meetup-on-the-24th-november\n\nYou received this message because you connected from the UK, Ireland, France or Belgium.',
|
||||
isByCreator: true,
|
||||
isRead: false,
|
||||
createdAt: new Date(),
|
||||
},
|
||||
],
|
||||
"creatorId": sender,
|
||||
"invitedId": user._id,
|
||||
"visibleByUserIds": [
|
||||
"lichess",
|
||||
user._id
|
||||
],
|
||||
"mod": true
|
||||
creatorId: sender,
|
||||
invitedId: user._id,
|
||||
visibleByUserIds: ['lichess', user._id],
|
||||
mod: true,
|
||||
});
|
||||
sent++;
|
||||
});
|
||||
|
|
|
@ -4,37 +4,43 @@ db.msg_thread.drop();
|
|||
function makeIndexes() {
|
||||
db.msg_thread.ensureIndex({ users: 1, 'lastMsg.date': -1 }, { background: 1 });
|
||||
db.msg_thread.ensureIndex({ users: 1 }, { partialFilterExpression: { 'lastMsg.read': false }, background: 1 });
|
||||
db.msg_msg.ensureIndex({tid:1,date:-1}, {background:1})
|
||||
db.msg_msg.ensureIndex({ tid: 1, date: -1 }, { background: 1 });
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
print("Delete old notifications");
|
||||
print('Delete old notifications');
|
||||
db.notify.remove({ 'content.type': 'privateMessage' });
|
||||
|
||||
if (!db.m_thread_sorted.count()) {
|
||||
print("Create db.m_thread_sorted");
|
||||
print('Create db.m_thread_sorted');
|
||||
db.m_thread_sorted.drop();
|
||||
db.m_thread.find({
|
||||
db.m_thread
|
||||
.find({
|
||||
mod: { $exists: false },
|
||||
visibleByUserIds: { $size: 2 },
|
||||
$or: [{
|
||||
creatorId: { $nin: ['lichess', 'lichess-qa', 'lichess-blog', 'lichess-team', 'mirlife', 'lichess4545', 'whatnext'] }
|
||||
}, {
|
||||
updatedAt: { $gt: new Date(Date.now() - 1000 * 3600 * 24 * 14) }
|
||||
}]
|
||||
}).forEach(t => {
|
||||
$or: [
|
||||
{
|
||||
creatorId: {
|
||||
$nin: ['lichess', 'lichess-qa', 'lichess-blog', 'lichess-team', 'mirlife', 'lichess4545', 'whatnext'],
|
||||
},
|
||||
},
|
||||
{
|
||||
updatedAt: { $gt: new Date(Date.now() - 1000 * 3600 * 24 * 14) },
|
||||
},
|
||||
],
|
||||
})
|
||||
.forEach(t => {
|
||||
if (t.creatorId == t.invitedId) return;
|
||||
t.visibleByUserIds.sort();
|
||||
db.m_thread_sorted.insert(t);
|
||||
});
|
||||
}
|
||||
|
||||
print("Create db.msg_thread");
|
||||
db.m_thread_sorted.aggregate([
|
||||
{$group:{_id:'$visibleByUserIds',threads:{$push:'$$ROOT'}}}
|
||||
],{ allowDiskUse: true }).forEach(o => {
|
||||
|
||||
print('Create db.msg_thread');
|
||||
db.m_thread_sorted
|
||||
.aggregate([{ $group: { _id: '$visibleByUserIds', threads: { $push: '$$ROOT' } } }], { allowDiskUse: true })
|
||||
.forEach(o => {
|
||||
let userIds = o.threads[0].visibleByUserIds;
|
||||
userIds.sort();
|
||||
let threadId = userIds.join('/');
|
||||
|
@ -49,7 +55,7 @@ db.m_thread_sorted.aggregate([
|
|||
tid: threadId,
|
||||
text: p.text,
|
||||
user: p.isByCreator ? t.creatorId : t.invitedId,
|
||||
date: p.createdAt
|
||||
date: p.createdAt,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -67,9 +73,9 @@ db.m_thread_sorted.aggregate([
|
|||
text: last.text.slice(0, 60),
|
||||
user: last.user,
|
||||
date: last.date,
|
||||
read: !o.threads.find(t => t.posts.find(p => p.isRead)) || isOld(last.date)
|
||||
}
|
||||
}
|
||||
read: !o.threads.find(t => t.posts.find(p => p.isRead)) || isOld(last.date),
|
||||
},
|
||||
};
|
||||
|
||||
db.msg_msg.insertMany(msgs, { ordered: false });
|
||||
try {
|
||||
|
|
|
@ -1,22 +1,36 @@
|
|||
db.user4.find({
|
||||
db.user4
|
||||
.find(
|
||||
{
|
||||
enabled: true,
|
||||
roles:{$in:['ROLE_SUPER_ADMIN', 'ROLE_ADMIN','ROLE_HUNTER','ROLE_SEE_REPORT']}
|
||||
},{_id:1, plan:1}).forEach(user => {
|
||||
|
||||
roles: { $in: ['ROLE_SUPER_ADMIN', 'ROLE_ADMIN', 'ROLE_HUNTER', 'ROLE_SEE_REPORT'] },
|
||||
},
|
||||
{ _id: 1, plan: 1 }
|
||||
)
|
||||
.forEach(user => {
|
||||
var userId = user._id;
|
||||
var prev = user.plan || {};
|
||||
|
||||
print(userId, !!prev.active);
|
||||
|
||||
db.user4.update({_id:userId},{$set:{plan:{
|
||||
db.user4.update(
|
||||
{ _id: userId },
|
||||
{
|
||||
$set: {
|
||||
plan: {
|
||||
months: NumberInt(prev.months || 1),
|
||||
active: true,
|
||||
since: prev.since || new Date()
|
||||
}}})
|
||||
since: prev.since || new Date(),
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
db.plan_patron.update({_id:userId}, {
|
||||
db.plan_patron.update(
|
||||
{ _id: userId },
|
||||
{
|
||||
lastLevelUp: new Date(),
|
||||
lifetime: true
|
||||
}, {upsert:true});
|
||||
|
||||
lifetime: true,
|
||||
},
|
||||
{ upsert: true }
|
||||
);
|
||||
});
|
||||
|
|
|
@ -2,13 +2,24 @@ var userId = 'shork'.toLowerCase();
|
|||
|
||||
var prev = db.user4.findOne({ _id: userId }).plan;
|
||||
|
||||
db.user4.update({_id:userId},{$set:{plan:{
|
||||
db.user4.update(
|
||||
{ _id: userId },
|
||||
{
|
||||
$set: {
|
||||
plan: {
|
||||
months: NumberInt(prev.months || 1),
|
||||
active: true,
|
||||
since: prev.since || new Date()
|
||||
}}})
|
||||
since: prev.since || new Date(),
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
db.plan_patron.update({_id:userId}, {
|
||||
db.plan_patron.update(
|
||||
{ _id: userId },
|
||||
{
|
||||
lastLevelUp: new Date(),
|
||||
lifetime: true
|
||||
}, {upsert:true});
|
||||
lifetime: true,
|
||||
},
|
||||
{ upsert: true }
|
||||
);
|
||||
|
|
|
@ -2,8 +2,10 @@ var u = 'neio'.toLowerCase();
|
|||
var since = new Date('2019-01-17');
|
||||
|
||||
function monthDiff(dateFrom, dateTo) {
|
||||
return dateTo.getMonth() - dateFrom.getMonth() +
|
||||
(12 * (dateTo.getFullYear() - dateFrom.getFullYear()))
|
||||
return dateTo.getMonth() - dateFrom.getMonth() + 12 * (dateTo.getFullYear() - dateFrom.getFullYear());
|
||||
}
|
||||
|
||||
db.user4.update({_id: u}, {$set: { 'plan.months': NumberInt(monthDiff(since, new Date()) + 1), 'plan.since': since}});
|
||||
db.user4.update(
|
||||
{ _id: u },
|
||||
{ $set: { 'plan.months': NumberInt(monthDiff(since, new Date()) + 1), 'plan.since': since } }
|
||||
);
|
||||
|
|
|
@ -1,87 +1,101 @@
|
|||
print("user.settings should not be an empty array, but an empty object");
|
||||
db.user2.find({settings:{'$in':[{},[]]}}).forEach(function(user) {
|
||||
db.user2.update({'_id': user['_id']}, {'$unset':{settings:true}});
|
||||
print('user.settings should not be an empty array, but an empty object');
|
||||
db.user2.find({ settings: { $in: [{}, []] } }).forEach(function (user) {
|
||||
db.user2.update({ _id: user['_id'] }, { $unset: { settings: true } });
|
||||
});
|
||||
|
||||
print("user.roles should not be an empty array, but an empty object");
|
||||
db.user2.find({roles:{'$in':[{},[]]}}).forEach(function(user) {
|
||||
db.user2.update({'_id': user['_id']}, {'$unset':{roles:true}});
|
||||
print('user.roles should not be an empty array, but an empty object');
|
||||
db.user2.find({ roles: { $in: [{}, []] } }).forEach(function (user) {
|
||||
db.user2.update({ _id: user['_id'] }, { $unset: { roles: true } });
|
||||
});
|
||||
|
||||
print("rename user.isChatBan -> user.troll");
|
||||
print('rename user.isChatBan -> user.troll');
|
||||
db.user2.update({}, { $rename: { isChatBan: 'troll' } }, { multi: true });
|
||||
|
||||
print("add troll fields to the forum topics")
|
||||
print('add troll fields to the forum topics');
|
||||
db.f_topic.find().forEach(function (topic) {
|
||||
db.f_topic.update({'_id': topic['_id']}, { $set: {
|
||||
db.f_topic.update(
|
||||
{ _id: topic['_id'] },
|
||||
{
|
||||
$set: {
|
||||
troll: false,
|
||||
updatedAtTroll: topic['updatedAt'],
|
||||
nbPostsTroll: topic['nbPosts'],
|
||||
lastPostIdTroll: topic['lastPostId']
|
||||
}});
|
||||
lastPostIdTroll: topic['lastPostId'],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
print("add troll fields to the forum categs")
|
||||
print('add troll fields to the forum categs');
|
||||
db.f_categ.find().forEach(function (categ) {
|
||||
db.f_categ.update({'_id': categ['_id']}, { $set: {
|
||||
db.f_categ.update(
|
||||
{ _id: categ['_id'] },
|
||||
{
|
||||
$set: {
|
||||
nbTopicsTroll: categ['nbTopics'],
|
||||
nbPostsTroll: categ['nbPosts'],
|
||||
lastPostIdTroll: categ['lastPostId']
|
||||
}});
|
||||
lastPostIdTroll: categ['lastPostId'],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
print("remove useless author names in forum posts")
|
||||
db.f_post.update({author:{$exists:true},userId:{$exists:true}},{$unset:{author:true}},{multi:true});
|
||||
print('remove useless author names in forum posts');
|
||||
db.f_post.update(
|
||||
{ author: { $exists: true }, userId: { $exists: true } },
|
||||
{ $unset: { author: true } },
|
||||
{ multi: true }
|
||||
);
|
||||
|
||||
print("mark all forum posts as not troll");
|
||||
print('mark all forum posts as not troll');
|
||||
db.f_post.update({}, { $set: { troll: false } }, { multi: true });
|
||||
|
||||
print("use troll field in forum post indexes")
|
||||
db.f_post.dropIndex('topicId_1')
|
||||
db.f_post.dropIndex('topicId_1_createdAt_1')
|
||||
db.f_post.dropIndex('categId_1')
|
||||
db.f_post.dropIndex('createdAt_-1')
|
||||
db.f_post.ensureIndex({topicId: 1, troll: 1})
|
||||
db.f_post.ensureIndex({topicId: 1, createdAt: 1, troll: 1})
|
||||
db.f_post.ensureIndex({categId: 1, troll: 1})
|
||||
db.f_post.ensureIndex({createdAt: -1, troll: 1})
|
||||
print('use troll field in forum post indexes');
|
||||
db.f_post.dropIndex('topicId_1');
|
||||
db.f_post.dropIndex('topicId_1_createdAt_1');
|
||||
db.f_post.dropIndex('categId_1');
|
||||
db.f_post.dropIndex('createdAt_-1');
|
||||
db.f_post.ensureIndex({ topicId: 1, troll: 1 });
|
||||
db.f_post.ensureIndex({ topicId: 1, createdAt: 1, troll: 1 });
|
||||
db.f_post.ensureIndex({ categId: 1, troll: 1 });
|
||||
db.f_post.ensureIndex({ createdAt: -1, troll: 1 });
|
||||
|
||||
print("use troll field in forum topic indexes")
|
||||
db.f_topic.dropIndex('categId_1')
|
||||
db.f_topic.dropIndex('categId_1_updatedAt_-1')
|
||||
db.f_topic.ensureIndex({categId: 1, troll: 1})
|
||||
db.f_topic.ensureIndex({categId: 1, updatedAt: -1, troll: 1})
|
||||
print('use troll field in forum topic indexes');
|
||||
db.f_topic.dropIndex('categId_1');
|
||||
db.f_topic.dropIndex('categId_1_updatedAt_-1');
|
||||
db.f_topic.ensureIndex({ categId: 1, troll: 1 });
|
||||
db.f_topic.ensureIndex({ categId: 1, updatedAt: -1, troll: 1 });
|
||||
|
||||
print("user.settings.{chat,sound} should be a string");
|
||||
print('user.settings.{chat,sound} should be a string');
|
||||
['settings.chat', 'settings.sound'].forEach(function (name) {
|
||||
[true, false].forEach(function (value) {
|
||||
var sel = {}
|
||||
var sel = {};
|
||||
sel[name] = value;
|
||||
db.user2.find(sel).forEach(function (user) {
|
||||
var up = {}
|
||||
var up = {};
|
||||
up[name] = value.toString();
|
||||
db.user2.update({'_id': user['_id']}, {'$set':up});
|
||||
db.user2.update({ _id: user['_id'] }, { $set: up });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
print('create relation collection');
|
||||
db.createCollection('relation')
|
||||
db.relation.ensureIndex({u1:1})
|
||||
db.relation.ensureIndex({u2:1})
|
||||
db.createCollection('relation');
|
||||
db.relation.ensureIndex({ u1: 1 });
|
||||
db.relation.ensureIndex({ u2: 1 });
|
||||
|
||||
print('index forum post authors');
|
||||
db.f_post.ensureIndex({userId:1})
|
||||
db.f_post.ensureIndex({ userId: 1 });
|
||||
|
||||
print('create timeline_entry collection');
|
||||
db.createCollection("timeline_entry",{capped:true,size:50000000})
|
||||
db.createCollection('timeline_entry', { capped: true, size: 50000000 });
|
||||
db.timeline_entry.ensureIndex({ user: 1, date: -1 });
|
||||
db.timeline_entry.ensureIndex({ type: 1, date: -1 });
|
||||
|
||||
print("Reset lobby_room");
|
||||
print('Reset lobby_room');
|
||||
db.lobby_room.drop();
|
||||
db.createCollection("lobby_room",{capped:true,size:50000})
|
||||
db.createCollection('lobby_room', { capped: true, size: 50000 });
|
||||
|
||||
print("Reset lobby_entry");
|
||||
print('Reset lobby_entry');
|
||||
db.lobby_entry.drop();
|
||||
db.createCollection("lobby_entry",{capped:true,size:10000})
|
||||
db.createCollection('lobby_entry', { capped: true, size: 10000 });
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
print("Migrating forum posts");
|
||||
print('Migrating forum posts');
|
||||
|
||||
db.f_post.dropIndex({ categId: 1 });
|
||||
|
||||
db.f_categ.find().forEach(function (categ) {
|
||||
db.f_topic.find({ categId: categ._id }).forEach(function (topic) {
|
||||
db.f_post.find({ topicId: topic._id }).forEach(function (post) {
|
||||
db.f_post.update({_id: post._id},{'$set':{categId: categ._id}}, false, false);
|
||||
db.f_post.update({ _id: post._id }, { $set: { categId: categ._id } }, false, false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
print("Building indexes");
|
||||
print('Building indexes');
|
||||
db.f_post.ensureIndex({ categId: 1 });
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -13,34 +13,41 @@ function makePly(fen) {
|
|||
return fen.split(' ')[1] === 'w' ? 0 : 1;
|
||||
}
|
||||
|
||||
var chapters = db.study_chapter.find({
|
||||
var chapters = db.study_chapter
|
||||
.find({
|
||||
studyId: {
|
||||
$in: studyIds
|
||||
}
|
||||
}).forEach(function(chapter) {
|
||||
|
||||
$in: studyIds,
|
||||
},
|
||||
})
|
||||
.forEach(function (chapter) {
|
||||
var fen = chapter.root.f;
|
||||
var fixed = fixFen(fen);
|
||||
if (fixed != fen) {
|
||||
print('Fix chapter FEN ' + chapter._id + ': ' + fixed);
|
||||
db.study_chapter.update({
|
||||
_id: chapter._id
|
||||
}, {
|
||||
db.study_chapter.update(
|
||||
{
|
||||
_id: chapter._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
'root.f': fixed
|
||||
'root.f': fixed,
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
var ply = makePly(fixed);
|
||||
if (chapter.root.p != ply) {
|
||||
print('Fix chapter root ply ' + chapter._id);
|
||||
db.study_chapter.update({
|
||||
_id: chapter._id
|
||||
}, {
|
||||
db.study_chapter.update(
|
||||
{
|
||||
_id: chapter._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
'root.p': NumberInt(ply)
|
||||
}
|
||||
});
|
||||
'root.p': NumberInt(ply),
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
const ids = 'BJy6fEDf fE4k21MW 8yadFPpU PDkQDt6u 96Lij7wH Rg2cMBZ6 9ogFv8Ac tuoBxVE5 Qj281y1p MnsJEWnI RUQASaZm o734CNqp ITWY4GN2 9cKgYrHb g1fxVZu9 s5pLU7Of xebrDvFe A4ujYOer pt20yRkT MkDViieT 9c6GrCTk Z1DKk4Rl'.split(' ');
|
||||
const ids = 'BJy6fEDf fE4k21MW 8yadFPpU PDkQDt6u 96Lij7wH Rg2cMBZ6 9ogFv8Ac tuoBxVE5 Qj281y1p MnsJEWnI RUQASaZm o734CNqp ITWY4GN2 9cKgYrHb g1fxVZu9 s5pLU7Of xebrDvFe A4ujYOer pt20yRkT MkDViieT 9c6GrCTk Z1DKk4Rl'.split(
|
||||
' '
|
||||
);
|
||||
|
||||
ids.forEach(id => {
|
||||
var study = db.study.findOne({ _id: id });
|
||||
print(`${study._id} ${study.name}`);
|
||||
db.study_chapter.find({
|
||||
db.study_chapter
|
||||
.find({
|
||||
studyId: id,
|
||||
'root.co': {$exists:1}
|
||||
}).forEach(chapter => {
|
||||
'root.co': { $exists: 1 },
|
||||
})
|
||||
.forEach(chapter => {
|
||||
print(' - ' + chapter._id + ' ' + chapter.name);
|
||||
db.study_chapter.update(
|
||||
{ _id: chapter._id },
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var props = ['animation', 'autoQueen', 'autoThreefold', 'challenge', 'coordColor', 'takeback'];
|
||||
db.pref.find().forEach(function (p) {
|
||||
var set = {}, unset = {};
|
||||
var set = {},
|
||||
unset = {};
|
||||
props.forEach(function (prop) {
|
||||
if (typeof p[prop] !== 'undefined') {
|
||||
unset[prop] = true;
|
||||
|
@ -8,16 +9,22 @@ db.pref.find().forEach(function(p) {
|
|||
}
|
||||
});
|
||||
// must unset first, or update does not happen D:
|
||||
db.pref.update({
|
||||
db.pref.update(
|
||||
{
|
||||
_id: p._id,
|
||||
}, {
|
||||
'$unset': set
|
||||
});
|
||||
db.pref.update({
|
||||
},
|
||||
{
|
||||
$unset: set,
|
||||
}
|
||||
);
|
||||
db.pref.update(
|
||||
{
|
||||
_id: p._id,
|
||||
}, {
|
||||
'$set': set
|
||||
});
|
||||
},
|
||||
{
|
||||
$set: set,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -16,30 +16,35 @@ function depthOf(obj) {
|
|||
return level;
|
||||
}
|
||||
|
||||
puzzles.find({
|
||||
"mate": true,
|
||||
"_id": {
|
||||
"$gt": 60120
|
||||
puzzles
|
||||
.find({
|
||||
mate: true,
|
||||
_id: {
|
||||
$gt: 60120,
|
||||
},
|
||||
'vote.sum': {
|
||||
'$gt': -8000
|
||||
}
|
||||
}).forEach(function(p) {
|
||||
$gt: -8000,
|
||||
},
|
||||
})
|
||||
.forEach(function (p) {
|
||||
var depth = depthOf(p);
|
||||
if (depth % 2 === 1) {
|
||||
count++;
|
||||
puzzles.update({
|
||||
_id: p._id
|
||||
}, {
|
||||
puzzles.update(
|
||||
{
|
||||
_id: p._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
vote: {
|
||||
up: NumberInt(0),
|
||||
down: NumberInt(9000),
|
||||
sum: NumberInt(-9000)
|
||||
sum: NumberInt(-9000),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
print(p._id);
|
||||
}
|
||||
});
|
||||
print("Disabled " + count + " puzzles");
|
||||
print('Disabled ' + count + ' puzzles');
|
||||
|
|
|
@ -10,18 +10,23 @@ function changeFenMoveNumber(fen, n) {
|
|||
return parts.join(' ');
|
||||
}
|
||||
|
||||
puzzles.find({
|
||||
"_id": {
|
||||
"$lt": 60121
|
||||
}
|
||||
}).forEach(function(p) {
|
||||
puzzles
|
||||
.find({
|
||||
_id: {
|
||||
$lt: 60121,
|
||||
},
|
||||
})
|
||||
.forEach(function (p) {
|
||||
var newMoveNumber = fullMoveNumber(p);
|
||||
var newFen = changeFenMoveNumber(p.fen, newMoveNumber);
|
||||
puzzles.update({
|
||||
_id: p._id
|
||||
}, {
|
||||
puzzles.update(
|
||||
{
|
||||
_id: p._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
fen: newFen
|
||||
fen: newFen,
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
db.puzzle.find({ tags: { $exists: true } }).forEach(function (o) {
|
||||
db.puzzle.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
db.puzzle.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
mate: o.tags.indexOf("forced mate") !== -1
|
||||
mate: o.tags.indexOf('forced mate') !== -1,
|
||||
},
|
||||
$unset: {
|
||||
tags: true
|
||||
tags: true,
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -2,20 +2,25 @@ var puzzles = db.puzzle;
|
|||
|
||||
modified = 0;
|
||||
|
||||
puzzles.find({
|
||||
'vote.ratio': {$exists: false}
|
||||
}).forEach(function(p) {
|
||||
puzzles.update({
|
||||
_id: p._id
|
||||
}, {
|
||||
puzzles
|
||||
.find({
|
||||
'vote.ratio': { $exists: false },
|
||||
})
|
||||
.forEach(function (p) {
|
||||
puzzles.update(
|
||||
{
|
||||
_id: p._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
"vote.ratio": NumberInt(100*(p.vote.up - p.vote.down)/(p.vote.up + p.vote.down)),
|
||||
"vote.nb": NumberInt(p.vote.up + p.vote.down)
|
||||
'vote.ratio': NumberInt((100 * (p.vote.up - p.vote.down)) / (p.vote.up + p.vote.down)),
|
||||
'vote.nb': NumberInt(p.vote.up + p.vote.down),
|
||||
},
|
||||
$unset: {
|
||||
'vote.sum': true
|
||||
'vote.sum': true,
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
modified += 1;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,36 +1,46 @@
|
|||
db.puzzle.find({
|
||||
db.puzzle
|
||||
.find({
|
||||
perf: {
|
||||
$exists: false
|
||||
}
|
||||
}).forEach(function(o) {
|
||||
db.puzzle.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
$exists: false,
|
||||
},
|
||||
})
|
||||
.forEach(function (o) {
|
||||
db.puzzle.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
perf: {
|
||||
gl: o.rating,
|
||||
nb: NumberInt(0)
|
||||
}
|
||||
nb: NumberInt(0),
|
||||
},
|
||||
},
|
||||
$unset: {
|
||||
rating: true
|
||||
rating: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
db.puzzle.find({
|
||||
db.puzzle
|
||||
.find({
|
||||
'vote.up': {
|
||||
$exists: false
|
||||
}
|
||||
}).forEach(function(o) {
|
||||
db.puzzle.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
$exists: false,
|
||||
},
|
||||
})
|
||||
.forEach(function (o) {
|
||||
db.puzzle.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
vote: {
|
||||
up: NumberInt(0),
|
||||
down: NumberInt(0),
|
||||
sum: NumberInt(0)
|
||||
}
|
||||
sum: NumberInt(0),
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,16 +1,25 @@
|
|||
// db.puzzle_round2.drop();
|
||||
|
||||
var shift = 60000, o = {}, m = 0, n = 0, total = db.puzzle_round.count();
|
||||
var shift = 60000,
|
||||
o = {},
|
||||
m = 0,
|
||||
n = 0,
|
||||
total = db.puzzle_round.count();
|
||||
|
||||
var noWin = ((1 << 30) - 1);
|
||||
var noWin = (1 << 30) - 1;
|
||||
|
||||
Number.prototype.pad = function (size) {
|
||||
var s = String(this);
|
||||
while (s.length < (size || 2)) {s = "0" + s;}
|
||||
return s;
|
||||
while (s.length < (size || 2)) {
|
||||
s = '0' + s;
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
db.puzzle_round.find().sort({$natural:-1}).forEach(r => {
|
||||
db.puzzle_round
|
||||
.find()
|
||||
.sort({ $natural: -1 })
|
||||
.forEach(r => {
|
||||
if (r.p < shift) return;
|
||||
m = r.w ? 1 << 31 : 0;
|
||||
m += Math.abs(r.d || 0) << 16;
|
||||
|
@ -18,18 +27,18 @@ db.puzzle_round.find().sort({$natural:-1}).forEach(r => {
|
|||
o = {
|
||||
_id: `${r.u}:${(r.p - shift).pad(5)}`,
|
||||
a: r.a,
|
||||
m: NumberInt(m)
|
||||
m: NumberInt(m),
|
||||
};
|
||||
var win = !!(m >>> 31);
|
||||
var rating = m << 16 >>> 16;
|
||||
var rating = (m << 16) >>> 16;
|
||||
var diff = ((m & noWin) >> 16) * (win ? 1 : -1);
|
||||
// printjson(r);
|
||||
// printjson(o);
|
||||
// print(win, rating, diff);
|
||||
try {
|
||||
if (win !== r.w) throw "bad win";
|
||||
if (rating !== r.r) throw "bad rating";
|
||||
if (diff !== r.d) throw "bad diff";
|
||||
if (win !== r.w) throw 'bad win';
|
||||
if (rating !== r.r) throw 'bad rating';
|
||||
if (diff !== r.d) throw 'bad diff';
|
||||
db.puzzle_round2.insert(o);
|
||||
} catch (e) {
|
||||
print(e, r._id);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
var coll = db.puzzle;
|
||||
coll.find({_id:{$lt:60120},'vote.sum':{$gte:100}}).sort({_id:1}).forEach(function(p) {
|
||||
coll
|
||||
.find({ _id: { $lt: 60120 }, 'vote.sum': { $gte: 100 } })
|
||||
.sort({ _id: 1 })
|
||||
.forEach(function (p) {
|
||||
if (coll.count({ fen: p.fen }) == 1) {
|
||||
var nextId = coll.find({}, { _id: 1 }).sort({ _id: -1 }).limit(1)[0]._id + 1;
|
||||
p.salvaged = NumberInt(p._id);
|
||||
|
|
|
@ -1,54 +1,86 @@
|
|||
db.puzzle2_round.aggregate([{
|
||||
db.puzzle2_round
|
||||
.aggregate(
|
||||
[
|
||||
{
|
||||
$match: {
|
||||
v: {
|
||||
$exists: 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$exists: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: {
|
||||
$arrayElemAt: [{
|
||||
$split: ['$_id', ':']
|
||||
}, 1]
|
||||
$arrayElemAt: [
|
||||
{
|
||||
$split: ['$_id', ':'],
|
||||
},
|
||||
1,
|
||||
],
|
||||
},
|
||||
vu: {
|
||||
$sum: {
|
||||
$cond: [{
|
||||
$gt: ['$v', 0]
|
||||
}, '$v', 0]
|
||||
}
|
||||
$cond: [
|
||||
{
|
||||
$gt: ['$v', 0],
|
||||
},
|
||||
'$v',
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
vd: {
|
||||
$sum: {
|
||||
$cond: [{
|
||||
$lt: ['$v', 0]
|
||||
}, {
|
||||
$subtract: [0, '$v']
|
||||
}, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$cond: [
|
||||
{
|
||||
$lt: ['$v', 0],
|
||||
},
|
||||
{
|
||||
$subtract: [0, '$v'],
|
||||
},
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 1,
|
||||
vu: 1,
|
||||
vd: 1,
|
||||
v: {
|
||||
$divide: [{
|
||||
$subtract: ['$vu', '$vd']
|
||||
}, {
|
||||
$add: ['$vu', '$vd']
|
||||
}]
|
||||
$divide: [
|
||||
{
|
||||
$subtract: ['$vu', '$vd'],
|
||||
},
|
||||
{
|
||||
$add: ['$vu', '$vd'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
{
|
||||
allowDiskUse: true,
|
||||
}
|
||||
}
|
||||
}], {
|
||||
allowDiskUse: true
|
||||
}).forEach(r => {
|
||||
db.puzzle2_puzzle.update({_id: r._id},{$set:{
|
||||
)
|
||||
.forEach(r => {
|
||||
db.puzzle2_puzzle.update(
|
||||
{ _id: r._id },
|
||||
{
|
||||
$set: {
|
||||
vote: r.v,
|
||||
vd: NumberInt(r.vd),
|
||||
vu: NumberInt(r.vu)
|
||||
}});
|
||||
vu: NumberInt(r.vu),
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
db.puzzle2_puzzle.update({vu:{$exists:0},vd:{$exists:0}}, {$set:{vote:1,vu:NumberInt(1),vd:NumberInt(0)}}, {multi:1});
|
||||
db.puzzle2_puzzle.update(
|
||||
{ vu: { $exists: 0 }, vd: { $exists: 0 } },
|
||||
{ $set: { vote: 1, vu: NumberInt(1), vd: NumberInt(0) } },
|
||||
{ multi: 1 }
|
||||
);
|
||||
|
|
|
@ -3,13 +3,22 @@ var ranking = db.ranking;
|
|||
|
||||
var cheats = [];
|
||||
|
||||
ranking.find({}, {
|
||||
user: 1
|
||||
}).forEach(function(r) {
|
||||
if (r.user && users.count({
|
||||
ranking
|
||||
.find(
|
||||
{},
|
||||
{
|
||||
user: 1,
|
||||
}
|
||||
)
|
||||
.forEach(function (r) {
|
||||
if (
|
||||
r.user &&
|
||||
users.count({
|
||||
_id: r.user,
|
||||
engine: true
|
||||
}) > 0) cheats.push(r._id);
|
||||
engine: true,
|
||||
}) > 0
|
||||
)
|
||||
cheats.push(r._id);
|
||||
});
|
||||
|
||||
print('Found ' + cheats.length);
|
||||
|
@ -17,6 +26,6 @@ print(cheats.join(', '));
|
|||
|
||||
cheats.forEach(function (id) {
|
||||
ranking.remove({
|
||||
_id: id
|
||||
_id: id,
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,23 +19,23 @@ function copyPerf(p) {
|
|||
gl: {
|
||||
r: p.gl.r,
|
||||
v: p.gl.v,
|
||||
d: p.gl.d
|
||||
d: p.gl.d,
|
||||
},
|
||||
nb: p.nb,
|
||||
re: p.re
|
||||
re: p.re,
|
||||
};
|
||||
}
|
||||
|
||||
var initialGlicko = {
|
||||
r: 1500,
|
||||
v: 0.06,
|
||||
d: 350
|
||||
d: 350,
|
||||
};
|
||||
|
||||
// var query = {_id:{$in:['thibault', 'neio']}};
|
||||
var query = {
|
||||
'perfs.classical.nb': { $gte: 1 },
|
||||
'v':{$exists:false}
|
||||
v: { $exists: false },
|
||||
};
|
||||
|
||||
var done = 0;
|
||||
|
@ -52,9 +52,10 @@ db.user4.find(query).forEach(u => {
|
|||
s: { $gte: 30 },
|
||||
ra: true,
|
||||
v: { $exists: false },
|
||||
c: { $exists: true }
|
||||
c: { $exists: true },
|
||||
};
|
||||
db.game5.find(gameQuery, { _id: false, c: true, ca: true })
|
||||
db.game5
|
||||
.find(gameQuery, { _id: false, c: true, ca: true })
|
||||
.sort({ ca: -1 })
|
||||
.hint('us_1_ca_-1')
|
||||
.forEach(g => {
|
||||
|
@ -81,8 +82,8 @@ db.user4.find(query).forEach(u => {
|
|||
|
||||
var update = {
|
||||
$set: {
|
||||
v: 2 // user version 2
|
||||
}
|
||||
v: 2, // user version 2
|
||||
},
|
||||
};
|
||||
|
||||
if (classicalPerf.nb == 0) update['$unset'] = { 'perfs.classical': true };
|
||||
|
|
|
@ -19,25 +19,25 @@ function copyPerf(p) {
|
|||
gl: {
|
||||
r: p.gl.r,
|
||||
v: p.gl.v,
|
||||
d: p.gl.d
|
||||
d: p.gl.d,
|
||||
},
|
||||
nb: p.nb,
|
||||
re: p.re
|
||||
re: p.re,
|
||||
};
|
||||
}
|
||||
|
||||
var initialGlicko = {
|
||||
r: 1500,
|
||||
v: 0.06,
|
||||
d: 350
|
||||
d: 350,
|
||||
};
|
||||
|
||||
// var query = {_id:{$in:['thibault', 'cyanfish']}};
|
||||
var query = {
|
||||
'perfs.classical.nb': { $gte: 1 },
|
||||
'v':{$exists:false},
|
||||
v: { $exists: false },
|
||||
// seenAt: { $gt: new Date(Date.now() - 1000 * 60 * 60 * 24) }
|
||||
seenAt: { $gt: new Date(Date.now() - 1000 * 60 * 60 * 1) }
|
||||
seenAt: { $gt: new Date(Date.now() - 1000 * 60 * 60 * 1) },
|
||||
};
|
||||
|
||||
var done = 0;
|
||||
|
@ -54,9 +54,10 @@ db.user4.find(query).forEach(u => {
|
|||
s: { $gte: 30 },
|
||||
ra: true,
|
||||
v: { $exists: false },
|
||||
c: { $exists: true }
|
||||
c: { $exists: true },
|
||||
};
|
||||
db.game5.find(gameQuery, { _id: false, c: true, ca: true })
|
||||
db.game5
|
||||
.find(gameQuery, { _id: false, c: true, ca: true })
|
||||
.sort({ ca: -1 })
|
||||
.hint('us_1_ca_-1')
|
||||
.forEach(g => {
|
||||
|
@ -83,8 +84,8 @@ db.user4.find(query).forEach(u => {
|
|||
|
||||
var update = {
|
||||
$set: {
|
||||
v: 2 // user version 2
|
||||
}
|
||||
v: 2, // user version 2
|
||||
},
|
||||
};
|
||||
|
||||
if (classicalPerf.nb == 0) update['$unset'] = { 'perfs.classical': true };
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
db.report2.drop();
|
||||
|
||||
db.report.aggregate(
|
||||
db.report
|
||||
.aggregate(
|
||||
[
|
||||
{$group:{
|
||||
{
|
||||
$group: {
|
||||
_id: {
|
||||
user: '$user',
|
||||
reason: '$reason',
|
||||
processedBy: '$processedBy'
|
||||
processedBy: '$processedBy',
|
||||
},
|
||||
reports: { $push: '$$ROOT' },
|
||||
},
|
||||
},
|
||||
reports:{$push:'$$ROOT'}
|
||||
}}
|
||||
],
|
||||
{ allowDiskUse: true }
|
||||
).toArray().forEach(group => {
|
||||
|
||||
)
|
||||
.toArray()
|
||||
.forEach(group => {
|
||||
var reports = group.reports;
|
||||
var first = reports[0];
|
||||
|
||||
|
@ -21,11 +25,12 @@ db.report.aggregate(
|
|||
reports.forEach(r => {
|
||||
var same = atoms.find(a => a.by === r.createdBy);
|
||||
if (same) same.text += '\n\n' + r.text;
|
||||
else atoms.push({
|
||||
else
|
||||
atoms.push({
|
||||
by: r.createdBy,
|
||||
at: r.createdAt,
|
||||
text: r.text,
|
||||
score: 30
|
||||
score: 30,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -36,10 +41,9 @@ db.report.aggregate(
|
|||
room: first.room,
|
||||
atoms: atoms,
|
||||
score: atoms.reduce((acc, atom) => acc + atom.score, 0),
|
||||
open: !first.processedBy
|
||||
open: !first.processedBy,
|
||||
};
|
||||
if (first.processedBy)
|
||||
report.processedBy = first.processedBy;
|
||||
if (first.processedBy) report.processedBy = first.processedBy;
|
||||
|
||||
db.report2.insert(report);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
db.report2.update({ room: 'coms' }, { $set: { room: 'comm' } }, { multi: 1 });
|
||||
|
||||
db.report2.distinct('user', { room: 'comm' }).forEach(user => {
|
||||
|
||||
const reports = db.report2.find({ user: user, room: 'comm' }).toArray();
|
||||
|
||||
const report = reports[0];
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
var lastWeek = new Date(Date.now() - 1000 * 60 * 60 * 24 * 7);
|
||||
|
||||
db.report.find().forEach(r => {
|
||||
|
||||
var room = 'others';
|
||||
if (!r.processedBy && r.createdAt < lastWeek) room = 'xfiles';
|
||||
else if (r.reason === 'cheat') room = 'cheat';
|
||||
|
|
|
@ -1,22 +1,32 @@
|
|||
db.report.find({
|
||||
db.report
|
||||
.find({
|
||||
processedBy: {
|
||||
$exists: false
|
||||
}
|
||||
}).sort({
|
||||
createdAt: -1
|
||||
}).skip(150).limit(1).toArray().forEach(function(report) {
|
||||
db.report.update({
|
||||
$exists: false,
|
||||
},
|
||||
})
|
||||
.sort({
|
||||
createdAt: -1,
|
||||
})
|
||||
.skip(150)
|
||||
.limit(1)
|
||||
.toArray()
|
||||
.forEach(function (report) {
|
||||
db.report.update(
|
||||
{
|
||||
processedBy: {
|
||||
$exists: false
|
||||
$exists: false,
|
||||
},
|
||||
createdAt: {
|
||||
$gt: report.createdAt
|
||||
}
|
||||
}, {
|
||||
$gt: report.createdAt,
|
||||
},
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
processedBy: 'lichess-sweep'
|
||||
processedBy: 'lichess-sweep',
|
||||
},
|
||||
},
|
||||
{
|
||||
multi: true,
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
const perf = 'rapid';
|
||||
|
||||
const ratings = {
|
||||
'STL_Caruana': 2773,
|
||||
'STL_Dominguez': 2786,
|
||||
'STL_So': 2741,
|
||||
'STL_Carlsen': 2881,
|
||||
STL_Caruana: 2773,
|
||||
STL_Dominguez: 2786,
|
||||
STL_So: 2741,
|
||||
STL_Carlsen: 2881,
|
||||
'STL_Vachier-Lagrave': 2860,
|
||||
'STL_Grischuk': 2784,
|
||||
'STL_Aronian': 2778,
|
||||
'STL_Xiong': 2730
|
||||
STL_Grischuk: 2784,
|
||||
STL_Aronian: 2778,
|
||||
STL_Xiong: 2730,
|
||||
};
|
||||
|
||||
for (k of Object.keys(ratings)) {
|
||||
|
@ -20,22 +20,26 @@ for (k of Object.keys(ratings)) {
|
|||
const push = {
|
||||
[`perfs.${perf}.re`]: {
|
||||
$each: [NumberInt(rating)],
|
||||
$position: 0
|
||||
}
|
||||
$position: 0,
|
||||
},
|
||||
};
|
||||
db.user4.update({ _id: id }, { $set: set, $push: push });
|
||||
}
|
||||
else {
|
||||
db.user4.update({_id:id},{$set:{
|
||||
} else {
|
||||
db.user4.update(
|
||||
{ _id: id },
|
||||
{
|
||||
$set: {
|
||||
[`perfs.${perf}`]: {
|
||||
"gl": {
|
||||
"r": rating,
|
||||
"d": 150,
|
||||
"v": 0.06
|
||||
gl: {
|
||||
r: rating,
|
||||
d: 150,
|
||||
v: 0.06,
|
||||
},
|
||||
nb: NumberInt(0),
|
||||
re: [],
|
||||
},
|
||||
},
|
||||
"nb": NumberInt(0),
|
||||
"re": [ ]
|
||||
}
|
||||
}});
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
var ids = [];
|
||||
|
||||
db.simul.find({
|
||||
status: 20
|
||||
}).forEach(function(s) {
|
||||
db.simul
|
||||
.find({
|
||||
status: 20,
|
||||
})
|
||||
.forEach(function (s) {
|
||||
var finished = true;
|
||||
printjson(s);
|
||||
s.pairings.forEach(function (p) {
|
||||
|
@ -11,16 +13,20 @@ db.simul.find({
|
|||
if (finished) ids.push(s._id);
|
||||
});
|
||||
|
||||
db.simul.update({
|
||||
db.simul.update(
|
||||
{
|
||||
_id: {
|
||||
$in: ids
|
||||
}
|
||||
}, {
|
||||
$in: ids,
|
||||
},
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
status: NumberInt(30),
|
||||
finishedAt: new Date(),
|
||||
hostGameId: null
|
||||
hostGameId: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
multi: 1,
|
||||
}
|
||||
}, {
|
||||
multi: 1
|
||||
});
|
||||
);
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
db.streamer.update({
|
||||
db.streamer.update(
|
||||
{
|
||||
liveAt: { $exists: 0 },
|
||||
createdAt:{$lt:new Date(Date.now() - 1000 * 3600 * 24 * 7)}
|
||||
},{
|
||||
createdAt: { $lt: new Date(Date.now() - 1000 * 3600 * 24 * 7) },
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
'approval.granted': false,
|
||||
demoted:true
|
||||
demoted: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
multi: 1,
|
||||
}
|
||||
},{
|
||||
multi:1
|
||||
})
|
||||
);
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
rs.slaveOk();
|
||||
var depth, maxDepth = 900;
|
||||
var depth,
|
||||
maxDepth = 900;
|
||||
|
||||
function depthOf(branch) { return 2 + Math.max(...(branch.n || []).map(depthOf),0); }
|
||||
function depthOf(branch) {
|
||||
return 2 + Math.max(...(branch.n || []).map(depthOf), 0);
|
||||
}
|
||||
|
||||
function urlOf(chap) {
|
||||
var study = db.study.findOne({ _id: chap.studyId });
|
||||
|
@ -15,4 +18,4 @@ db.study_chapter.find().forEach(chap => {
|
|||
} catch (e) {
|
||||
print(`${urlOf(chap)} ${e}`);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
db.study_chapter.find({
|
||||
db.study_chapter
|
||||
.find({
|
||||
// _id: 'MiRw4nlk',
|
||||
tags: {
|
||||
$exists: false
|
||||
}
|
||||
}).forEach(function(c) {
|
||||
$exists: false,
|
||||
},
|
||||
})
|
||||
.forEach(function (c) {
|
||||
var tags = c.setup.fromPgn ? c.setup.fromPgn.tags : [];
|
||||
db.study_chapter.update({
|
||||
_id: c._id
|
||||
}, {
|
||||
db.study_chapter.update(
|
||||
{
|
||||
_id: c._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
tags: tags
|
||||
tags: tags,
|
||||
},
|
||||
$unset: {
|
||||
'setup.fromPgn': !!c.setup.fromPgn
|
||||
'setup.fromPgn': !!c.setup.fromPgn,
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -23,9 +23,7 @@ const dotRegex = /\./g;
|
|||
const dollarRegex = /\$/g;
|
||||
|
||||
function encodePath(path) {
|
||||
return path ? path
|
||||
.replace(dotRegex, String.fromCharCode(144))
|
||||
.replace(dollarRegex, String.fromCharCode(145)) : '';
|
||||
return path ? path.replace(dotRegex, String.fromCharCode(144)).replace(dollarRegex, String.fromCharCode(145)) : '';
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
|
@ -40,16 +38,20 @@ let batch = [];
|
|||
const batchSize = 1000;
|
||||
const totalNb = (db.study_chapter_backup.count() - db.study_chapter_flat.count()) / parallelism;
|
||||
|
||||
db.study_chapter_backup.aggregate([
|
||||
{$lookup:{
|
||||
db.study_chapter_backup
|
||||
.aggregate([
|
||||
{
|
||||
$lookup: {
|
||||
from: 'study_chapter_flat',
|
||||
as: 'flat',
|
||||
let: { id: '$_id' },
|
||||
pipeline:[{$match:{$expr:{$eq:['$_id', '$$id']}}},{$project:{_id:1}}]
|
||||
}},
|
||||
pipeline: [{ $match: { $expr: { $eq: ['$_id', '$$id'] } } }, { $project: { _id: 1 } }],
|
||||
},
|
||||
},
|
||||
{ $match: { flat: [] } },
|
||||
{ $project:{flat:false} }
|
||||
]).forEach(c => {
|
||||
{ $project: { flat: false } },
|
||||
])
|
||||
.forEach(c => {
|
||||
try {
|
||||
sumSizeFrom += Object.bsonsize(c);
|
||||
} catch (e) {
|
||||
|
@ -72,14 +74,20 @@ db.study_chapter_backup.aggregate([
|
|||
if (i % batchSize == 0) {
|
||||
coll.insertMany(batch, {
|
||||
ordered: false,
|
||||
writeConcern: { w: 0, j: false }
|
||||
writeConcern: { w: 0, j: false },
|
||||
});
|
||||
batch = [];
|
||||
const at = Date.now();
|
||||
const perSecond = Math.round(batchSize / (at - lastAt) * 1000);
|
||||
const percent = 100 * i / totalNb;
|
||||
const perSecond = Math.round((batchSize / (at - lastAt)) * 1000);
|
||||
const percent = (100 * i) / totalNb;
|
||||
const minutesLeft = Math.round((totalNb - i) / perSecond / 60);
|
||||
print(`${i} ${percent.toFixed(2)}% ${perSecond}/s ETA ${minutesLeft} minutes | size:${(sumSizeFrom / batchSize).toFixed(0)}->${(sumSizeTo / batchSize).toFixed(0)} moves:${(sumMoves / batchSize).toFixed(0)} big:${tooBigNb} deep:${tooDeepNb}`);
|
||||
print(
|
||||
`${i} ${percent.toFixed(2)}% ${perSecond}/s ETA ${minutesLeft} minutes | size:${(
|
||||
sumSizeFrom / batchSize
|
||||
).toFixed(0)}->${(sumSizeTo / batchSize).toFixed(0)} moves:${(sumMoves / batchSize).toFixed(
|
||||
0
|
||||
)} big:${tooBigNb} deep:${tooDeepNb}`
|
||||
);
|
||||
lastAt = at;
|
||||
sumSizeFrom = 0;
|
||||
sumSizeTo = 0;
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
db.study.find({}, { members: 1 }).forEach(s => {
|
||||
|
||||
for (let i in s.members) {
|
||||
delete s.members[i].addedAt;
|
||||
}
|
||||
|
||||
db.study.update({ _id: s._id }, { $set: { members: s.members } });
|
||||
|
||||
});
|
||||
|
|
|
@ -9,8 +9,7 @@ function dig(chapId, node, path) {
|
|||
set[`${path}.n`] = [];
|
||||
printjson(set);
|
||||
db.study_chapter.update({ _id: chapId }, { $set: set });
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dig(chapId, c, newPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
db.study.createIndex({topics:1,rank:-1},{partialFilterExpression:{topics:{$exists:1}},background:1})
|
||||
db.study.createIndex({topics:1,createdAt:-1},{partialFilterExpression:{topics:{$exists:1}},background:1})
|
||||
db.study.createIndex({topics:1,updatedAt:-1},{partialFilterExpression:{topics:{$exists:1}},background:1})
|
||||
db.study.createIndex({topics:1,likes:-1},{partialFilterExpression:{topics:{$exists:1}},background:1})
|
||||
db.study.createIndex({uids:1,rank:-1},{partialFilterExpression:{topics:{$exists:1}},background:1})
|
||||
db.study.createIndex({ topics: 1, rank: -1 }, { partialFilterExpression: { topics: { $exists: 1 } }, background: 1 });
|
||||
db.study.createIndex(
|
||||
{ topics: 1, createdAt: -1 },
|
||||
{ partialFilterExpression: { topics: { $exists: 1 } }, background: 1 }
|
||||
);
|
||||
db.study.createIndex(
|
||||
{ topics: 1, updatedAt: -1 },
|
||||
{ partialFilterExpression: { topics: { $exists: 1 } }, background: 1 }
|
||||
);
|
||||
db.study.createIndex({ topics: 1, likes: -1 }, { partialFilterExpression: { topics: { $exists: 1 } }, background: 1 });
|
||||
db.study.createIndex({ uids: 1, rank: -1 }, { partialFilterExpression: { topics: { $exists: 1 } }, background: 1 });
|
||||
|
|
|
@ -1,34 +1,43 @@
|
|||
db.tournament.aggregate({
|
||||
db.tournament
|
||||
.aggregate(
|
||||
{
|
||||
$match: {
|
||||
_id: "eY3dydc7"
|
||||
}
|
||||
}, {
|
||||
_id: 'eY3dydc7',
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
'pairings.u': true,
|
||||
_id: false
|
||||
}
|
||||
}, {
|
||||
$unwind: '$pairings'
|
||||
}, {
|
||||
$unwind: '$pairings.u'
|
||||
}, {
|
||||
_id: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: '$pairings',
|
||||
},
|
||||
{
|
||||
$unwind: '$pairings.u',
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: '$pairings.u',
|
||||
nb: {
|
||||
$sum: 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$sum: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
nb: {
|
||||
$gte: 5
|
||||
$gte: 5,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}).result.forEach(function(r) {
|
||||
)
|
||||
.result.forEach(function (r) {
|
||||
db.trophy.insert({
|
||||
_id: 'survivor/' + r._id,
|
||||
kind: 'marathonSurvivor',
|
||||
user: r._id,
|
||||
date: new Date()
|
||||
date: new Date(),
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,16 +1,25 @@
|
|||
db.swiss.find({featurable:true,startsAt:{$lt:new Date(Date.now() - 1000 * 3600 * 24)},'settings.i':{$lt:3600 * 24}}).forEach(s => {
|
||||
db.swiss
|
||||
.find({
|
||||
featurable: true,
|
||||
startsAt: { $lt: new Date(Date.now() - 1000 * 3600 * 24) },
|
||||
'settings.i': { $lt: 3600 * 24 },
|
||||
})
|
||||
.forEach(s => {
|
||||
print(`FINISH ${s._id} ${s.name} round:${s.round}`);
|
||||
db.swiss.update({_id:s._id},{
|
||||
db.swiss.update(
|
||||
{ _id: s._id },
|
||||
{
|
||||
$set: {
|
||||
finishedAt: new Date(),
|
||||
'settings.n': s.round,
|
||||
canceled: new Date()
|
||||
canceled: new Date(),
|
||||
},
|
||||
$unset: {
|
||||
nextRoundAt: 1,
|
||||
featurable: 1
|
||||
featurable: 1,
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
||||
db.swiss.find({ nbOngoing: { $ne: 0 } }).forEach(s => {
|
||||
|
@ -18,7 +27,7 @@ db.swiss.find({nbOngoing:{$ne:0}}).forEach(s => {
|
|||
if (count != s.nbOngoing) {
|
||||
print(`nbOngoing ${s._id} ${s.name} ${s.nbOngoing} -> ${count}`);
|
||||
const set = {
|
||||
nbOngoing:NumberInt(count)
|
||||
nbOngoing: NumberInt(count),
|
||||
};
|
||||
if (!s.finishedAt) set.nextRoundAt = new Date(Date.now() + 1000 * 30);
|
||||
db.swiss.update({ _id: s._id }, { $set: set });
|
||||
|
|
|
@ -2,20 +2,24 @@ db.swiss_player.dropIndex('s_1_u_1');
|
|||
db.swiss_player.dropIndex('s_1_n_1');
|
||||
|
||||
db.swiss.find().forEach(swiss => {
|
||||
|
||||
let index = {};
|
||||
db.swiss_player.find({ s: swiss._id }).forEach(p => {
|
||||
index[p.n] = p.u;
|
||||
});
|
||||
|
||||
db.swiss_pairing.find({ s: swiss._id }).forEach(p => {
|
||||
db.swiss_pairing.update({_id:p._id},{$set:{
|
||||
db.swiss_pairing.update(
|
||||
{ _id: p._id },
|
||||
{
|
||||
$set: {
|
||||
p: [index[p.p[0]], index[p.p[1]]],
|
||||
t: p.t == p.p[0] ? NumberInt(0) : (p.t == p.p[1] ? NumberInt(1) : p.t)
|
||||
}});
|
||||
t: p.t == p.p[0] ? NumberInt(0) : p.t == p.p[1] ? NumberInt(1) : p.t,
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
db.swiss_player.update({ s: swiss._id }, { $unset: { n: 1 } }, { multi: 1 });
|
||||
});
|
||||
|
||||
db.swiss.ensureIndex({nbPlayers:-1},{partialFilterExpression:{featurable:true,'settings.i':{$lte:600}}})
|
||||
db.swiss.ensureIndex({ nbPlayers: -1 }, { partialFilterExpression: { featurable: true, 'settings.i': { $lte: 600 } } });
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
db.swiss.dropIndexes()
|
||||
db.swiss_player.dropIndexes()
|
||||
db.swiss_pairing.dropIndexes()
|
||||
db.swiss.dropIndexes();
|
||||
db.swiss_player.dropIndexes();
|
||||
db.swiss_pairing.dropIndexes();
|
||||
|
||||
db.swiss.ensureIndex({teamId:1,startsAt:-1})
|
||||
db.swiss.ensureIndex({ teamId: 1, startsAt: -1 });
|
||||
|
||||
db.swiss_player.ensureIndex({s:1,u:1})
|
||||
db.swiss_player.ensureIndex({s:1,n:1},{unique:true})
|
||||
db.swiss_player.ensureIndex({s:1,c:-1})
|
||||
db.swiss_player.ensureIndex({ s: 1, u: 1 });
|
||||
db.swiss_player.ensureIndex({ s: 1, n: 1 }, { unique: true });
|
||||
db.swiss_player.ensureIndex({ s: 1, c: -1 });
|
||||
|
||||
db.swiss_pairing.ensureIndex({s:1,r:1})
|
||||
db.swiss_pairing.ensureIndex({s:1,p:1,r:1})
|
||||
db.swiss_pairing.ensureIndex({t:1}, {partialFilterExpression:{t:true}})
|
||||
db.swiss_pairing.ensureIndex({ s: 1, r: 1 });
|
||||
db.swiss_pairing.ensureIndex({ s: 1, p: 1, r: 1 });
|
||||
db.swiss_pairing.ensureIndex({ t: 1 }, { partialFilterExpression: { t: true } });
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
print("Removing closed users memberships");
|
||||
print('Removing closed users memberships');
|
||||
|
||||
db.team_member.find().forEach(function (member) {
|
||||
var user = db.user2.findOne({ _id: member.user });
|
||||
if (!user || !user.enabled) {
|
||||
print("Removing " + member._id);
|
||||
print('Removing ' + member._id);
|
||||
db.team_member.remove({ _id: member._id });
|
||||
}
|
||||
});
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
db.tournament2.dropIndex('teamBattle.teams_1_startsAt_-1');
|
||||
db.tournament2.dropIndex('conditions.teamMember.teamId_1_startsAt_-1');
|
||||
db.tournament2.ensureIndex({forTeams:1,startsAt:-1},{partialFilterExpression:{forTeams:{$exists:1}}})
|
||||
db.tournament2.ensureIndex({ forTeams: 1, startsAt: -1 }, { partialFilterExpression: { forTeams: { $exists: 1 } } });
|
||||
|
||||
db.tournament2.find({'teamBattle':{$exists:1}}).forEach(t => db.tournament2.update({_id:t._id},{$set:{forTeams:t.teamBattle.teams}}))
|
||||
db.tournament2
|
||||
.find({ teamBattle: { $exists: 1 } })
|
||||
.forEach(t => db.tournament2.update({ _id: t._id }, { $set: { forTeams: t.teamBattle.teams } }));
|
||||
|
||||
db.tournament2.find({'conditions.teamMember.teamId':{$exists:1}}).forEach(t => db.tournament2.update({_id:t._id},{$set:{forTeams:[t.conditions.teamMember.teamId]}}))
|
||||
db.tournament2
|
||||
.find({ 'conditions.teamMember.teamId': { $exists: 1 } })
|
||||
.forEach(t => db.tournament2.update({ _id: t._id }, { $set: { forTeams: [t.conditions.teamMember.teamId] } }));
|
||||
|
|
|
@ -5,8 +5,8 @@ var userIds = db.user4.distinct('_id', {
|
|||
enabled: true,
|
||||
title: {
|
||||
$exists: true,
|
||||
$nin: ['LM', 'BOT']
|
||||
}
|
||||
$nin: ['LM', 'BOT'],
|
||||
},
|
||||
});
|
||||
'thibault arex'.split(' ').forEach(u => userIds.push(u));
|
||||
|
||||
|
@ -15,21 +15,24 @@ print('Inviting ' + userIds.join(', '));
|
|||
var invited = 0;
|
||||
|
||||
userIds.forEach(userId => {
|
||||
if (db.notify.count({
|
||||
if (
|
||||
db.notify.count({
|
||||
notifies: userId,
|
||||
'content.type': 'titledTourney',
|
||||
'content.id': tournamentId
|
||||
})) return;
|
||||
'content.id': tournamentId,
|
||||
})
|
||||
)
|
||||
return;
|
||||
db.notify.insert({
|
||||
_id: Math.random().toString(36).substring(2, 10),
|
||||
notifies: userId,
|
||||
content: {
|
||||
type: 'titledTourney',
|
||||
id: tournamentId,
|
||||
text: text
|
||||
text: text,
|
||||
},
|
||||
read: false,
|
||||
createdAt: new Date()
|
||||
createdAt: new Date(),
|
||||
});
|
||||
invited++;
|
||||
});
|
||||
|
|
1540
bin/mongodb/tor.js
1540
bin/mongodb/tor.js
File diff suppressed because one or more lines are too long
|
@ -4,17 +4,23 @@ function toInt(obj) {
|
|||
};
|
||||
}
|
||||
// db.tournament.find({_id:'fefNHKaL'}).forEach(function(tour) {
|
||||
db.tournament.find().sort({createdAt: -1}).forEach(function(tour) {
|
||||
db.tournament
|
||||
.find()
|
||||
.sort({ createdAt: -1 })
|
||||
.forEach(function (tour) {
|
||||
['status', 'mode', 'variant', 'system', 'minutes', 'minPlayers'].forEach(toInt(tour));
|
||||
if (tour.pairings) tour.pairings.forEach(function(pairing) {
|
||||
if (tour.pairings)
|
||||
tour.pairings.forEach(function (pairing) {
|
||||
['s', 't'].forEach(toInt(pairing));
|
||||
});
|
||||
if (tour.players) tour.players.forEach(function(player) {
|
||||
if (tour.players)
|
||||
tour.players.forEach(function (player) {
|
||||
['rating', 'score'].forEach(toInt(player));
|
||||
});
|
||||
if (tour.events) tour.events.forEach(function(event) {
|
||||
if (tour.events)
|
||||
tour.events.forEach(function (event) {
|
||||
toInt(event)('i');
|
||||
});
|
||||
if (tour.clock) ['limit', 'increment'].forEach(toInt(tour.clock));
|
||||
db.tournament.update({"_id": tour._id}, tour);
|
||||
db.tournament.update({ _id: tour._id }, tour);
|
||||
});
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
db.tournament2.find({
|
||||
startsAt: {"$gt": new Date()}
|
||||
}, {
|
||||
db.tournament2
|
||||
.find(
|
||||
{
|
||||
startsAt: { $gt: new Date() },
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
startsAt: 1
|
||||
}).forEach(d => {
|
||||
startsAt: 1,
|
||||
}
|
||||
)
|
||||
.forEach(d => {
|
||||
if (d.startsAt.getSeconds() === 0) {
|
||||
printjson(d);
|
||||
d.startsAt.setSeconds(Math.floor(Math.random() * 59 + 1));
|
||||
db.tournament2.update({_id: d._id}, {
|
||||
db.tournament2.update(
|
||||
{ _id: d._id },
|
||||
{
|
||||
$set: {
|
||||
startsAt: d.startsAt
|
||||
}
|
||||
});
|
||||
startsAt: d.startsAt,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,5 +5,5 @@ db.tournament.find({}, {players:1}).forEach(function(tour) {
|
|||
delete p.elo;
|
||||
tour.players[i] = p;
|
||||
}
|
||||
db.tournament.update({"_id": tour._id}, {"$set":{players: tour.players}});
|
||||
db.tournament.update({ _id: tour._id }, { $set: { players: tour.players } });
|
||||
});
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
db.tournament2.createIndex({'conditions.teamMember.teamId':1,startsAt:-1},{partialFilterExpression:{'conditions.teamMember':{$exists:1}}});
|
||||
db.tournament2.createIndex({'teamBattle.teams':1,startsAt:-1},{partialFilterExpression:{teamBattle:{$exists:1}}});
|
||||
db.tournament_player.createIndex({tid:1,t:1,m:-1},{partialFilterExpression:{t:{$exists:true}}},{background:true});
|
||||
db.tournament2.createIndex(
|
||||
{ 'conditions.teamMember.teamId': 1, startsAt: -1 },
|
||||
{ partialFilterExpression: { 'conditions.teamMember': { $exists: 1 } } }
|
||||
);
|
||||
db.tournament2.createIndex(
|
||||
{ 'teamBattle.teams': 1, startsAt: -1 },
|
||||
{ partialFilterExpression: { teamBattle: { $exists: 1 } } }
|
||||
);
|
||||
db.tournament_player.createIndex(
|
||||
{ tid: 1, t: 1, m: -1 },
|
||||
{ partialFilterExpression: { t: { $exists: true } } },
|
||||
{ background: true }
|
||||
);
|
||||
|
|
|
@ -10,36 +10,38 @@ var pause = 500;
|
|||
// players.drop();
|
||||
|
||||
dest.ensureIndex({
|
||||
status: 1
|
||||
status: 1,
|
||||
});
|
||||
dest.ensureIndex({
|
||||
createdAt: 1
|
||||
createdAt: 1,
|
||||
});
|
||||
dest.ensureIndex({
|
||||
startsAt: 1
|
||||
startsAt: 1,
|
||||
});
|
||||
pairings.ensureIndex({
|
||||
tid: 1,
|
||||
d: -1
|
||||
d: -1,
|
||||
});
|
||||
pairings.ensureIndex({
|
||||
tid: 1,
|
||||
u: 1,
|
||||
d: -1
|
||||
d: -1,
|
||||
});
|
||||
players.ensureIndex({
|
||||
tid: 1,
|
||||
uid: 1
|
||||
uid: 1,
|
||||
});
|
||||
players.ensureIndex({
|
||||
tid: 1,
|
||||
m: -1
|
||||
m: -1,
|
||||
});
|
||||
|
||||
var cursor = orig.find({
|
||||
status: 30
|
||||
}).sort({
|
||||
createdAt: -1
|
||||
var cursor = orig
|
||||
.find({
|
||||
status: 30,
|
||||
})
|
||||
.sort({
|
||||
createdAt: -1,
|
||||
}); //.limit(max);
|
||||
|
||||
function int(i) {
|
||||
|
@ -49,7 +51,7 @@ function int(i) {
|
|||
var uidIt = 0;
|
||||
|
||||
function uid() {
|
||||
return "i" + uidIt++;
|
||||
return 'i' + uidIt++;
|
||||
}
|
||||
|
||||
var it = 0;
|
||||
|
@ -68,7 +70,7 @@ cursor.forEach(function(o) {
|
|||
var ms = Math.round(1000 * (dat2 - dat - pause / 1000));
|
||||
var perSec = Math.round(batchSize / ms);
|
||||
dat = dat2;
|
||||
print(it + " " + percent + "% " + ms + "ms");
|
||||
print(it + ' ' + percent + '% ' + ms + 'ms');
|
||||
sleep(pause);
|
||||
}
|
||||
});
|
||||
|
@ -82,7 +84,7 @@ function insertPlayers(o) {
|
|||
tid: o._id,
|
||||
uid: p.id,
|
||||
r: int(p.rating),
|
||||
m: int(p.score * 1000000 + (p.perf || 0) * 1000 + p.rating)
|
||||
m: int(p.score * 1000000 + (p.perf || 0) * 1000 + p.rating),
|
||||
};
|
||||
if (p.withdraw) n.w = true;
|
||||
if (p.prov) n.pr = true;
|
||||
|
@ -102,7 +104,7 @@ function insertPairings(o) {
|
|||
tid: o._id,
|
||||
s: int(p.s),
|
||||
u: p.u,
|
||||
t: int(p.t)
|
||||
t: int(p.t),
|
||||
};
|
||||
if (p.w) n.w = p.w == p.u[0];
|
||||
if (p.b1) n.b1 = int(p.b1);
|
||||
|
@ -128,9 +130,10 @@ function mkTour(o) {
|
|||
if (o.system && o.system != 1) n.system = int(o.system);
|
||||
if (o.variant && o.variant != 1) n.variant = int(o.variant);
|
||||
if (o.mode && o.mode != 1) n.mode = int(o.mode);
|
||||
if (o.schedule) n.schedule = {
|
||||
if (o.schedule)
|
||||
n.schedule = {
|
||||
freq: o.schedule.freq,
|
||||
speed: o.schedule.speed
|
||||
speed: o.schedule.speed,
|
||||
};
|
||||
if (nbPlayers) n.winner = o.players[0].id;
|
||||
return n;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
print("move user nb* to user.count.*");
|
||||
print('move user nb* to user.count.*');
|
||||
db.user2.find().forEach(function (user) {
|
||||
db.user2.update({
|
||||
'_id': user['_id']
|
||||
}, {
|
||||
'$unset': {
|
||||
db.user2.update(
|
||||
{
|
||||
_id: user['_id'],
|
||||
},
|
||||
{
|
||||
$unset: {
|
||||
nbAi: true,
|
||||
nbDraws: true,
|
||||
nbDrawsH: true,
|
||||
|
@ -12,9 +14,9 @@ db.user2.find().forEach(function(user) {
|
|||
nbLossesH: true,
|
||||
nbRatedGames: true,
|
||||
nbWins: true,
|
||||
nbWinsH: true
|
||||
nbWinsH: true,
|
||||
},
|
||||
'$set': {
|
||||
$set: {
|
||||
count: {
|
||||
ai: user.nbAi || 0,
|
||||
draw: user.nbDraws || 0,
|
||||
|
@ -24,8 +26,9 @@ db.user2.find().forEach(function(user) {
|
|||
lossH: user.nbLossesH || 0,
|
||||
rated: user.nbRatedGames || 0,
|
||||
win: user.nbWins || 0,
|
||||
winH: user.nbWinsH || 0
|
||||
}
|
||||
winH: user.nbWinsH || 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
var user = db.user4.findOne({ _id: 'thibault' });
|
||||
var connections = [];
|
||||
db.security.find({user:user._id,$or:[{up:true},{date:{$gt:new Date(Date.now() - 1000 * 3600 * 24 * 30 * 6)}}]})
|
||||
.map(o => `${o.ip} ${o.ua}`).
|
||||
forEach(conn => {
|
||||
db.security
|
||||
.find({ user: user._id, $or: [{ up: true }, { date: { $gt: new Date(Date.now() - 1000 * 3600 * 24 * 30 * 6) } }] })
|
||||
.map(o => `${o.ip} ${o.ua}`)
|
||||
.forEach(conn => {
|
||||
if (!connections.find(c => c === conn)) connections.push(conn);
|
||||
});
|
||||
|
||||
print(`\n${user.username} ${user.email}`);
|
||||
|
||||
print("\nConnections\n-----------");
|
||||
print('\nConnections\n-----------');
|
||||
print(connections.join('\n'));
|
||||
|
|
|
@ -1,27 +1,34 @@
|
|||
var it = 0;
|
||||
var batchSize = 100;
|
||||
|
||||
db.user4.find({
|
||||
db.user4
|
||||
.find({
|
||||
createdAt: {
|
||||
$gt: ISODate("2015-02-03T20:00:09.148Z")
|
||||
}
|
||||
}).forEach(function(u) {
|
||||
|
||||
db.user4.update({
|
||||
_id: u._id
|
||||
}, {
|
||||
$unset: {
|
||||
createdAt: true
|
||||
}
|
||||
});
|
||||
|
||||
db.user4.update({
|
||||
_id: u._id
|
||||
}, {
|
||||
$set: {
|
||||
createdAt: u.createdAt
|
||||
}
|
||||
$gt: ISODate('2015-02-03T20:00:09.148Z'),
|
||||
},
|
||||
})
|
||||
.forEach(function (u) {
|
||||
db.user4.update(
|
||||
{
|
||||
_id: u._id,
|
||||
},
|
||||
{
|
||||
$unset: {
|
||||
createdAt: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
db.user4.update(
|
||||
{
|
||||
_id: u._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
createdAt: u.createdAt,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
++it;
|
||||
if (it % batchSize == 0) {
|
||||
|
@ -30,4 +37,4 @@ db.user4.find({
|
|||
}
|
||||
});
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -1,124 +1,168 @@
|
|||
var username = 'jamesflynn';
|
||||
var userId = username.toLowerCase();
|
||||
var user = db.user4.findOne({
|
||||
_id: userId
|
||||
_id: userId,
|
||||
});
|
||||
if (!user) throw 'No such user';
|
||||
var multi = {
|
||||
multi: true
|
||||
multi: true,
|
||||
};
|
||||
print('\n\n Delete user ' + user.username + ' with ' + user.count.game + ' games!\n\n');
|
||||
sleep(5000);
|
||||
|
||||
print('Set black games as anon');
|
||||
print(db.game5.update({
|
||||
print(
|
||||
db.game5.update(
|
||||
{
|
||||
us: userId,
|
||||
'us.1': userId
|
||||
}, {
|
||||
$pull: {
|
||||
us: userId
|
||||
'us.1': userId,
|
||||
},
|
||||
$unset: { p1: true }
|
||||
}, multi).nModified + ' done');
|
||||
{
|
||||
$pull: {
|
||||
us: userId,
|
||||
},
|
||||
$unset: { p1: true },
|
||||
},
|
||||
multi
|
||||
).nModified + ' done'
|
||||
);
|
||||
|
||||
print('Set white games as anon');
|
||||
print(db.game5.update({
|
||||
print(
|
||||
db.game5.update(
|
||||
{
|
||||
us: userId,
|
||||
'us.0': userId
|
||||
}, {
|
||||
$set: {
|
||||
'us.0': ''
|
||||
'us.0': userId,
|
||||
},
|
||||
$unset: { p0: true }
|
||||
}, multi).nModified + ' done');
|
||||
{
|
||||
$set: {
|
||||
'us.0': '',
|
||||
},
|
||||
$unset: { p0: true },
|
||||
},
|
||||
multi
|
||||
).nModified + ' done'
|
||||
);
|
||||
print('done');
|
||||
|
||||
print('Delete old PMs');
|
||||
print(db.m_thread.remove({
|
||||
visibleByUserIds: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.m_thread.remove({
|
||||
visibleByUserIds: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete new PMs');
|
||||
print(db.msg_thread.remove({
|
||||
users: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.msg_thread.remove({
|
||||
users: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete mod log');
|
||||
print(db.modlog.remove({
|
||||
user: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.modlog.remove({
|
||||
user: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete rating history');
|
||||
print(db.history3.remove({
|
||||
_id: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.history3.remove({
|
||||
_id: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete bookmarks');
|
||||
print(db.bookmark.remove({
|
||||
u: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.bookmark.remove({
|
||||
u: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete learn progress');
|
||||
print(db.learn_progress.remove({
|
||||
_id: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.learn_progress.remove({
|
||||
_id: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete perf stats');
|
||||
var nb = 0;
|
||||
for (var i = 5; i <= 20; i++)
|
||||
nb += db.perf_stat.remove({
|
||||
_id: userId + '/' + i
|
||||
}).nRemoved
|
||||
_id: userId + '/' + i,
|
||||
}).nRemoved;
|
||||
print(nb + ' done');
|
||||
|
||||
print('Delete prefs');
|
||||
print(db.pref.remove({
|
||||
_id: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.pref.remove({
|
||||
_id: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete relations from');
|
||||
print(db.relation.remove({
|
||||
u1: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.relation.remove({
|
||||
u1: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete relations to');
|
||||
print(db.relation.remove({
|
||||
u2: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.relation.remove({
|
||||
u2: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete security data');
|
||||
print(db.security.remove({
|
||||
user: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.security.remove({
|
||||
user: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete team membership');
|
||||
print(db.team_member.remove({
|
||||
user: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.team_member.remove({
|
||||
user: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete playbans');
|
||||
print(db.playban.remove({
|
||||
_id: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.playban.remove({
|
||||
_id: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete perf stats');
|
||||
print(db.perf_stat.remove({
|
||||
_id: new RegExp('^' + userId + '/')
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.perf_stat.remove({
|
||||
_id: new RegExp('^' + userId + '/'),
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete activity');
|
||||
print(db.activity.remove({
|
||||
_id: new RegExp('^' + userId + ':')
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.activity.remove({
|
||||
_id: new RegExp('^' + userId + ':'),
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete assessments');
|
||||
print(db.player_assessment.remove({
|
||||
userId: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.player_assessment.remove({
|
||||
userId: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('Delete user');
|
||||
print(db.user4.remove({
|
||||
_id: userId
|
||||
}).nRemoved + ' done');
|
||||
print(
|
||||
db.user4.remove({
|
||||
_id: userId,
|
||||
}).nRemoved + ' done'
|
||||
);
|
||||
|
||||
print('\n complete.');
|
||||
|
|
|
@ -1,15 +1,23 @@
|
|||
var coll = db.user4;
|
||||
|
||||
print("Migrating " + coll.count() + " users");
|
||||
print('Migrating ' + coll.count() + ' users');
|
||||
|
||||
coll.find({}, {
|
||||
_id: 1
|
||||
}).forEach(function(u) {
|
||||
coll.update({
|
||||
_id: u._id
|
||||
}, {
|
||||
$set: {
|
||||
len: NumberInt(u._id.length)
|
||||
coll
|
||||
.find(
|
||||
{},
|
||||
{
|
||||
_id: 1,
|
||||
}
|
||||
});
|
||||
)
|
||||
.forEach(function (u) {
|
||||
coll.update(
|
||||
{
|
||||
_id: u._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
len: NumberInt(u._id.length),
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var usersToMigrate = db.user2.find();
|
||||
var collection = db.user3;
|
||||
|
||||
print("Migrating " + usersToMigrate.count() + " users");
|
||||
print('Migrating ' + usersToMigrate.count() + ' users');
|
||||
|
||||
collection.drop();
|
||||
|
||||
|
@ -10,11 +10,10 @@ function nn(x) {
|
|||
}
|
||||
|
||||
usersToMigrate.forEach(function (u) {
|
||||
|
||||
if ((u.bio | '') !== '') u.profile = { bio: u.bio };
|
||||
delete u.bio;
|
||||
|
||||
collection.insert(u);
|
||||
});
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -2,7 +2,11 @@ var games = db.game5;
|
|||
var users = db.user4;
|
||||
|
||||
var batchSize = 1000;
|
||||
var i, t, timeStrings, times, it=0;
|
||||
var i,
|
||||
t,
|
||||
timeStrings,
|
||||
times,
|
||||
it = 0;
|
||||
var dat = new Date().getTime() / 1000;
|
||||
var max = users.count();
|
||||
|
||||
|
@ -10,27 +14,27 @@ function hintWid(query) {
|
|||
return games.find(query).hint({ wid: 1 }).length();
|
||||
}
|
||||
|
||||
print("Denormalize counts");
|
||||
print('Denormalize counts');
|
||||
users.find().forEach(function (user) {
|
||||
var uid = user._id;
|
||||
var count = {
|
||||
game: games.count({'us': uid}),
|
||||
win: games.count({"wid": uid}),
|
||||
loss: games.count({"us": uid, "s": { "$in": [ 30, 31, 35, 33 ] }, "wid": {"$ne": uid}}),
|
||||
draw: games.count({"us": uid, "s": { "$in": [34, 32] }}),
|
||||
winH: hintWid({"wid": uid, "p.ai":{$exists:false}}),
|
||||
lossH: games.count({"us": uid, "s": { "$in": [ 30, 31, 35, 33 ] }, "wid": {"$ne": uid}, "p.ai":{$exists:false}}),
|
||||
drawH: games.count({"us": uid, "s": { "$in": [34, 32] }, "p.ai":{$exists:false}}),
|
||||
ai: games.count({"us": uid, $or:[{'p0.ai':{$exists:true}},{'p1.ai':{$exists:true}}]}),
|
||||
rated: games.count({"us": uid, "ra":true}),
|
||||
game: games.count({ us: uid }),
|
||||
win: games.count({ wid: uid }),
|
||||
loss: games.count({ us: uid, s: { $in: [30, 31, 35, 33] }, wid: { $ne: uid } }),
|
||||
draw: games.count({ us: uid, s: { $in: [34, 32] } }),
|
||||
winH: hintWid({ wid: uid, 'p.ai': { $exists: false } }),
|
||||
lossH: games.count({ us: uid, s: { $in: [30, 31, 35, 33] }, wid: { $ne: uid }, 'p.ai': { $exists: false } }),
|
||||
drawH: games.count({ us: uid, s: { $in: [34, 32] }, 'p.ai': { $exists: false } }),
|
||||
ai: games.count({ us: uid, $or: [{ 'p0.ai': { $exists: true } }, { 'p1.ai': { $exists: true } }] }),
|
||||
rated: games.count({ us: uid, ra: true }),
|
||||
};
|
||||
users.update({"_id": uid}, {"$set":{count: count}});
|
||||
users.update({ _id: uid }, { $set: { count: count } });
|
||||
++it;
|
||||
if (it % batchSize === 0) {
|
||||
var percent = Math.round((it / max) * 100);
|
||||
var dat2 = new Date().getTime() / 1000;
|
||||
var perSec = Math.round(batchSize / (dat2 - dat));
|
||||
dat = dat2;
|
||||
print((it / 1000) + "k " + percent + "% " + perSec + "/s");
|
||||
print(it / 1000 + 'k ' + percent + '% ' + perSec + '/s');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
var variantId = 10;
|
||||
[db.config, db.config_anon].forEach(function(coll) { coll.update({ 'filter.v.1': { $exists: true } }, { $push: { 'filter.v': NumberInt(variantId) } }, { multi: true }); });
|
||||
[db.config, db.config_anon].forEach(function (coll) {
|
||||
coll.update({ 'filter.v.1': { $exists: true } }, { $push: { 'filter.v': NumberInt(variantId) } }, { multi: true });
|
||||
});
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
db.tournament2.insert({
|
||||
"_id": "wesley02",
|
||||
"clock": {
|
||||
"limit": NumberInt(3 * 60),
|
||||
"increment": NumberInt(0)
|
||||
_id: 'wesley02',
|
||||
clock: {
|
||||
limit: NumberInt(3 * 60),
|
||||
increment: NumberInt(0),
|
||||
},
|
||||
"createdAt": new Date(),
|
||||
"createdBy": "lichess",
|
||||
"minutes": NumberInt(60),
|
||||
"name": "GM Wesley So Arena",
|
||||
"nbPlayers": NumberInt(0),
|
||||
"startsAt": ISODate("2016-03-02T22:00:00Z"),
|
||||
"schedule": {
|
||||
"freq": "unique",
|
||||
"speed": "blitz"
|
||||
createdAt: new Date(),
|
||||
createdBy: 'lichess',
|
||||
minutes: NumberInt(60),
|
||||
name: 'GM Wesley So Arena',
|
||||
nbPlayers: NumberInt(0),
|
||||
startsAt: ISODate('2016-03-02T22:00:00Z'),
|
||||
schedule: {
|
||||
freq: 'unique',
|
||||
speed: 'blitz',
|
||||
},
|
||||
status: NumberInt(10),
|
||||
variant: NumberInt(1),
|
||||
spotlight: {
|
||||
homepageHours: 24,
|
||||
headline: 'Tournament by Chess at Three',
|
||||
description:
|
||||
'Your chance to play Super GM Wesley So! Tournament organized and [livestreamed](www.twitch.tv/chessat3) by [chessat3.com](http://chessat3.com).',
|
||||
iconImg: 'chessat3.logo.png',
|
||||
},
|
||||
"status": NumberInt(10),
|
||||
"variant": NumberInt(1),
|
||||
"spotlight": {
|
||||
"homepageHours": 24,
|
||||
"headline": "Tournament by Chess at Three",
|
||||
"description": "Your chance to play Super GM Wesley So! Tournament organized and [livestreamed](www.twitch.tv/chessat3) by [chessat3.com](http://chessat3.com).",
|
||||
"iconImg": "chessat3.logo.png"
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,39 +1,48 @@
|
|||
var gamesToMigrate = db.game5.find({
|
||||
var gamesToMigrate = db.game5.find(
|
||||
{
|
||||
w: {
|
||||
$exists: true
|
||||
$exists: true,
|
||||
},
|
||||
wid: {
|
||||
$exists: false
|
||||
$exists: false,
|
||||
},
|
||||
us: {
|
||||
$exists: true
|
||||
$exists: true,
|
||||
},
|
||||
ca: {
|
||||
$gt: ISODate("2013-12-15T10:55:07.702Z")
|
||||
}
|
||||
}, {
|
||||
$gt: ISODate('2013-12-15T10:55:07.702Z'),
|
||||
},
|
||||
},
|
||||
{
|
||||
us: 1,
|
||||
w: 1
|
||||
});
|
||||
w: 1,
|
||||
}
|
||||
);
|
||||
|
||||
gamesToMigrate.forEach(function (g) {
|
||||
if (g.w && typeof g.us[0] != 'undefined' && g.us[0]) {
|
||||
db.game5.update({
|
||||
_id: g._id
|
||||
}, {
|
||||
db.game5.update(
|
||||
{
|
||||
_id: g._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
wid: g.us[0]
|
||||
wid: g.us[0],
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
} else if (!g.w && typeof g.us[1] != 'undefined' && g.us[1]) {
|
||||
db.game5.update({
|
||||
_id: g._id
|
||||
}, {
|
||||
db.game5.update(
|
||||
{
|
||||
_id: g._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
wid: g.us[1]
|
||||
wid: g.us[1],
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -1,37 +1,49 @@
|
|||
var gamesToMigrate = db.game5.find({
|
||||
$or: [{
|
||||
'p0.w': true
|
||||
}, {
|
||||
'p1.w': true
|
||||
var gamesToMigrate = db.game5
|
||||
.find(
|
||||
{
|
||||
$or: [
|
||||
{
|
||||
'p0.w': true,
|
||||
},
|
||||
{
|
||||
'p1.w': true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'p0.w': true,
|
||||
}
|
||||
]
|
||||
}, {
|
||||
'p0.w': true
|
||||
}).sort({ca:-1});
|
||||
)
|
||||
.sort({ ca: -1 });
|
||||
|
||||
gamesToMigrate.forEach(function (g) {
|
||||
var color = !!(g.p0 && g.p0.w);
|
||||
var update = {
|
||||
$unset: color ? {
|
||||
'p0.w': true
|
||||
} : {
|
||||
'p1.w': true
|
||||
$unset: color
|
||||
? {
|
||||
'p0.w': true,
|
||||
}
|
||||
: {
|
||||
'p1.w': true,
|
||||
},
|
||||
$set: {
|
||||
w: color
|
||||
}
|
||||
w: color,
|
||||
},
|
||||
};
|
||||
// printjson(g);
|
||||
// printjson(update);
|
||||
// print(' ');
|
||||
db.game5.update({
|
||||
_id: g._id
|
||||
}, update);
|
||||
db.game5.update(
|
||||
{
|
||||
_id: g._id,
|
||||
},
|
||||
update
|
||||
);
|
||||
});
|
||||
|
||||
print("Unsetting empty players...");
|
||||
print('Unsetting empty players...');
|
||||
|
||||
db.game5.update({ p0: {} }, { $unset: { p0: 1 } }, { multi: true });
|
||||
db.game5.update({ p1: {} }, { $unset: { p1: 1 } }, { multi: true });
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -5,7 +5,9 @@ const port = parseInt(process.argv[2]);
|
|||
const dir = process.argv[3];
|
||||
const delay = parseInt(process.argv[4] || 1000);
|
||||
|
||||
let files, file, completion = -1;
|
||||
let files,
|
||||
file,
|
||||
completion = -1;
|
||||
|
||||
fs.readdir(dir).then(list => {
|
||||
files = list.filter(n => n.endsWith('.pgn'));
|
||||
|
@ -14,7 +16,7 @@ fs.readdir(dir).then(list => {
|
|||
|
||||
function serveIndex(index) {
|
||||
if (!files[index]) index = 0;
|
||||
const percent = Math.floor(index * 100 / files.length);
|
||||
const percent = Math.floor((index * 100) / files.length);
|
||||
if (percent > completion) {
|
||||
completion = percent;
|
||||
console.log(`${percent}%`);
|
||||
|
@ -23,15 +25,19 @@ function serveIndex(index) {
|
|||
setTimeout(() => serveIndex(index + 1, delay), delay);
|
||||
}
|
||||
|
||||
http.createServer((request, response) => {
|
||||
http
|
||||
.createServer((request, response) => {
|
||||
const path = `${dir}/${file}`;
|
||||
return fs.readFile(path, {
|
||||
encoding: 'utf8'
|
||||
}).then(content => {
|
||||
return fs
|
||||
.readFile(path, {
|
||||
encoding: 'utf8',
|
||||
})
|
||||
.then(content => {
|
||||
console.log(`${path} ${content.length}`);
|
||||
response.end(content)
|
||||
response.end(content);
|
||||
});
|
||||
}).listen(port, err => {
|
||||
})
|
||||
.listen(port, err => {
|
||||
if (err) return console.log(err);
|
||||
console.log(`server is listening on ${port}`);
|
||||
});
|
||||
|
|
|
@ -2,7 +2,9 @@ const fs = require('fs').promises;
|
|||
const parseString = require('xml2js').parseString;
|
||||
|
||||
const baseDir = 'translation/source';
|
||||
const dbs = 'site arena emails learn activity coordinates study clas contact patron coach broadcast streamer tfa settings preferences team perfStat search tourname faq lag swiss puzzle puzzleTheme challenge storm'.split(' ');
|
||||
const dbs = 'site arena emails learn activity coordinates study clas contact patron coach broadcast streamer tfa settings preferences team perfStat search tourname faq lag swiss puzzle puzzleTheme challenge storm'.split(
|
||||
' '
|
||||
);
|
||||
|
||||
function ucfirst(s) {
|
||||
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||
|
@ -14,23 +16,26 @@ function xmlName(name) {
|
|||
|
||||
function keyListFrom(name) {
|
||||
return fs.readFile(`${baseDir}/${xmlName(name)}.xml`, { encoding: 'utf8' }).then(txt => {
|
||||
return new Promise((resolve, reject) => parseString(txt, (_, xml) => {
|
||||
return new Promise((resolve, reject) =>
|
||||
parseString(txt, (_, xml) => {
|
||||
const strings = (xml.resources.string || []).map(e => e['$'].name);
|
||||
const plurals = (xml.resources.plurals || []).map(e => e['$'].name);
|
||||
const keys = strings.concat(plurals);
|
||||
resolve({
|
||||
name: name,
|
||||
code: keys.map(k => 'val `' + k + '` = new I18nKey("' + (name == 'site' ? '' : xmlName(name) + ':') + k + '")').join('\n') + '\n',
|
||||
code:
|
||||
keys
|
||||
.map(k => 'val `' + k + '` = new I18nKey("' + (name == 'site' ? '' : xmlName(name) + ':') + k + '")')
|
||||
.join('\n') + '\n',
|
||||
});
|
||||
}));
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Promise.all(dbs.map(keyListFrom)).then(objs => {
|
||||
function dbCode(obj) {
|
||||
return obj.name === 'site' ?
|
||||
obj.code :
|
||||
`object ${obj.name} {\n${obj.code}}\n`;
|
||||
return obj.name === 'site' ? obj.code : `object ${obj.name} {\n${obj.code}}\n`;
|
||||
}
|
||||
const code = `// Generated with bin/trans-dump.js
|
||||
package lila.i18n
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
```sh
|
||||
http --form POST l.org/setup/ai variant=1 clock=false time=60 increment=60 level=3 color=random 'Accept:application/vnd.lichess.v1+json'
|
||||
```
|
||||
|
||||
- level: 1 to 8
|
||||
- color: white | black | random
|
||||
- variant: 1 (standard) | 2 (chess960) | 3 (from position) | 4 (KotH) | 5 (three-check)
|
||||
- fen: if variant is 3, any valid FEN string
|
||||
|
||||
Response: `201 CREATED`
|
||||
|
||||
```javascript
|
||||
{
|
||||
// see document format in the play.md doc file
|
||||
|
@ -35,11 +37,13 @@ Once connected, you can send seeks over HTTP, using the same clientId
|
|||
```sh
|
||||
http --form POST l.org/setup/hook/{clientId} variant=1 clock=false time=60 increment=60 mode=casual 'Accept:application/vnd.lichess.v1+json'
|
||||
```
|
||||
|
||||
- clientId: same random ID created by the client and used to connect to the lobby websocket
|
||||
- variant: 1 (standard) | 2 (chess960) | 3 (from position) | 4 (KotH)
|
||||
- mode: casual | rated
|
||||
|
||||
Response: `200 OK`
|
||||
|
||||
```
|
||||
ok
|
||||
```
|
||||
|
@ -59,11 +63,13 @@ Now you're waiting for someone to accept the seek. The response will come as a s
|
|||
```sh
|
||||
http --form POST l.org/setup/friend?user=usernameOrId variant=1 clock=false time=60 increment=60 color=random 'Accept:application/vnd.lichess.v1+json'
|
||||
```
|
||||
|
||||
- color: white | black | random
|
||||
- variant: 1 (standard) | 2 (chess960) | 3 (from position) | 4 (KotH) | 5 (three-check)
|
||||
- fen: if variant is 3, any valid FEN string
|
||||
|
||||
Response: `201 CREATED`
|
||||
|
||||
```javascript
|
||||
{
|
||||
// see document format in the play.md doc file
|
||||
|
@ -131,6 +137,7 @@ http GET l.org/39b12Ikl 'Accept:application/vnd.lichess.v1+json'
|
|||
```
|
||||
|
||||
Response: `200 OK`
|
||||
|
||||
```javascript
|
||||
{
|
||||
// see document format in the Play section
|
||||
|
|
|
@ -8,7 +8,9 @@ Request the list of your online friends from any authenticated websocket connect
|
|||
|
||||
```javascript
|
||||
// send
|
||||
{t: 'following_onlines'}
|
||||
{
|
||||
t: 'following_onlines';
|
||||
}
|
||||
```
|
||||
|
||||
The server answers with:
|
||||
|
|
|
@ -18,6 +18,7 @@ The client is responsible for creating and storing its own unique `clientId`.
|
|||
It will be sent to the server when connecting to a websocket.
|
||||
|
||||
Suggestion of implementation:
|
||||
|
||||
```javascript
|
||||
var clientId = Math.random().toString(36).substring(2);
|
||||
```
|
||||
|
|
|
@ -9,9 +9,11 @@ http --form POST l.org/login username=thibault password=xxxxxxxx 'Accept:applica
|
|||
```
|
||||
|
||||
Response: `200 OK`
|
||||
|
||||
```
|
||||
Set-Cookie: lila2="3b5cc8c80f0af258a31dc4fd1b5381cabe7388c7-sessionId=80q7V5stkKIu"; Expires=Tue, 21 Jul 2015 20:31:43 GMT; Path=/; Domain=.l.org; HTTPOnly
|
||||
```
|
||||
|
||||
```javascript
|
||||
{
|
||||
"username": "thibault",
|
||||
|
|
|
@ -10,9 +10,9 @@ Parameters and result are similar to the users games API.
|
|||
|
||||
Returns tournament info, and a page of the tournament standing
|
||||
|
||||
name | type | default | description
|
||||
--- | --- | --- | ---
|
||||
**page** | int | 1 | for standing pagination
|
||||
| name | type | default | description |
|
||||
| -------- | ---- | ------- | ----------------------- |
|
||||
| **page** | int | 1 | for standing pagination |
|
||||
|
||||
```
|
||||
curl 'https://lichess.org/api/tournament/x5WNIngd?page=1'
|
||||
|
|
|
@ -5,7 +5,6 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
lichess.loadScript('javascripts/chart/common.js').then(function () {
|
||||
lichess.loadScript('javascripts/chart/division.js').then(function () {
|
||||
lichess.chartCommon('highchart').then(function () {
|
||||
|
||||
lichess.advantageChart.update = function (d) {
|
||||
el.highcharts && el.highcharts.series[0].setData(makeSerieData(d));
|
||||
};
|
||||
|
@ -16,8 +15,8 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
var makeSerieData = function (d) {
|
||||
var partial = !d.analysis || d.analysis.partial;
|
||||
return d.treeParts.slice(1).map(function (node) {
|
||||
|
||||
var color = node.ply & 1, cp;
|
||||
var color = node.ply & 1,
|
||||
cp;
|
||||
|
||||
if (node.eval && node.eval.mate) {
|
||||
cp = node.eval.mate > 0 ? Infinity : -Infinity;
|
||||
|
@ -26,15 +25,16 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
if (d.game.variant.key === 'antichess') cp = -cp;
|
||||
} else if (node.eval && typeof node.eval.cp !== 'undefined') {
|
||||
cp = node.eval.cp;
|
||||
} else return {
|
||||
y: null
|
||||
} else
|
||||
return {
|
||||
y: null,
|
||||
};
|
||||
|
||||
var turn = Math.floor((node.ply - 1) / 2) + 1;
|
||||
var dots = color === 1 ? '.' : '...';
|
||||
var point = {
|
||||
name: turn + dots + ' ' + node.san,
|
||||
y: 2 / (1 + Math.exp(-0.004 * cp)) - 1
|
||||
y: 2 / (1 + Math.exp(-0.004 * cp)) - 1,
|
||||
};
|
||||
if (!partial && blurs[color].shift() === '1') {
|
||||
point.marker = {
|
||||
|
@ -42,7 +42,7 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
radius: 3,
|
||||
lineWidth: '1px',
|
||||
lineColor: '#d85000',
|
||||
fillColor: color ? '#fff' : '#333'
|
||||
fillColor: color ? '#fff' : '#333',
|
||||
};
|
||||
point.name += ' [blur]';
|
||||
}
|
||||
|
@ -51,27 +51,29 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
};
|
||||
|
||||
var disabled = {
|
||||
enabled: false
|
||||
enabled: false,
|
||||
};
|
||||
var noText = {
|
||||
text: null
|
||||
text: null,
|
||||
};
|
||||
var serieData = makeSerieData(data);
|
||||
el.highcharts = Highcharts.chart(el, {
|
||||
credits: disabled,
|
||||
legend: disabled,
|
||||
series: [{
|
||||
series: [
|
||||
{
|
||||
name: trans('advantage'),
|
||||
data: serieData
|
||||
}],
|
||||
data: serieData,
|
||||
},
|
||||
],
|
||||
chart: {
|
||||
type: 'area',
|
||||
spacing: [3, 0, 3, 0],
|
||||
animation: false
|
||||
animation: false,
|
||||
},
|
||||
plotOptions: {
|
||||
series: {
|
||||
animation: false
|
||||
animation: false,
|
||||
},
|
||||
area: {
|
||||
fillColor: Highcharts.theme.lichess.area.white,
|
||||
|
@ -83,8 +85,8 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
cursor: 'pointer',
|
||||
states: {
|
||||
hover: {
|
||||
lineWidth: 1
|
||||
}
|
||||
lineWidth: 1,
|
||||
},
|
||||
},
|
||||
events: {
|
||||
click: function (event) {
|
||||
|
@ -92,22 +94,22 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
event.point.select();
|
||||
lichess.pubsub.emit('analysis.chart.click', event.point.x);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
marker: {
|
||||
radius: 1,
|
||||
states: {
|
||||
hover: {
|
||||
radius: 4,
|
||||
lineColor: '#d85000'
|
||||
lineColor: '#d85000',
|
||||
},
|
||||
select: {
|
||||
radius: 4,
|
||||
lineColor: '#d85000'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lineColor: '#d85000',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
pointFormatter: function (format) {
|
||||
|
@ -120,7 +122,7 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
if (e > 0) e = '+' + e;
|
||||
return format.replace('{point.y}', e);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
title: noText,
|
||||
xAxis: {
|
||||
|
@ -128,7 +130,7 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
labels: disabled,
|
||||
lineWidth: 0,
|
||||
tickWidth: 0,
|
||||
plotLines: lichess.divisionLines(data.game.division, trans)
|
||||
plotLines: lichess.divisionLines(data.game.division, trans),
|
||||
},
|
||||
yAxis: {
|
||||
title: noText,
|
||||
|
@ -139,12 +141,14 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
labels: disabled,
|
||||
lineWidth: 1,
|
||||
gridLineWidth: 0,
|
||||
plotLines: [{
|
||||
plotLines: [
|
||||
{
|
||||
color: Highcharts.theme.lichess.text.weak,
|
||||
width: 1,
|
||||
value: 0
|
||||
}]
|
||||
}
|
||||
value: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
lichess.pubsub.emit('analysis.change.trigger');
|
||||
});
|
||||
|
|
|
@ -2,7 +2,9 @@ lichess.highchartsPromise;
|
|||
lichess.chartCommon = function (type) {
|
||||
if (lichess.highchartsPromise) return lichess.highchartsPromise;
|
||||
var file = type === 'highstock' ? 'highstock.js' : 'highcharts.js';
|
||||
return lichess.highchartsPromise = lichess.loadScript('vendor/highcharts-4.2.5/' + file, { noVersion: true }).then(function() {
|
||||
return (lichess.highchartsPromise = lichess
|
||||
.loadScript('vendor/highcharts-4.2.5/' + file, { noVersion: true })
|
||||
.then(function () {
|
||||
// Drop-in fix for Highcharts issue #8477 on older Highcharts versions. The
|
||||
// issue is fixed since Highcharts v6.1.1.
|
||||
Highcharts.wrap(Highcharts.Axis.prototype, 'getPlotLinePath', function (proceed) {
|
||||
|
@ -17,26 +19,36 @@ lichess.chartCommon = function(type) {
|
|||
var light = $('body').hasClass('light');
|
||||
var text = {
|
||||
weak: light ? '#a0a0a0' : '#707070',
|
||||
strong: light ? '#707070' : '#a0a0a0'
|
||||
strong: light ? '#707070' : '#a0a0a0',
|
||||
};
|
||||
var line = {
|
||||
weak: light ? '#ccc' : '#404040',
|
||||
strong: light ? '#a0a0a0' : '#606060',
|
||||
fat: '#d85000' // light ? '#a0a0a0' : '#707070'
|
||||
fat: '#d85000', // light ? '#a0a0a0' : '#707070'
|
||||
};
|
||||
var area = {
|
||||
white: light ? 'rgba(255,255,255,0.7)' : 'rgba(255,255,255,0.3)',
|
||||
black: light ? 'rgba(0,0,0,0.2)' : 'rgba(0,0,0,1)'
|
||||
black: light ? 'rgba(0,0,0,0.2)' : 'rgba(0,0,0,1)',
|
||||
};
|
||||
return {
|
||||
light: light,
|
||||
lichess: {
|
||||
text: text,
|
||||
line: line,
|
||||
area: area
|
||||
area: area,
|
||||
},
|
||||
colors: ["#DDDF0D", "#7798BF", "#55BF3B", "#DF5353", "#aaeeee", "#ff0066", "#eeaaee",
|
||||
"#55BF3B", "#DF5353", "#7798BF", "#aaeeee"
|
||||
colors: [
|
||||
'#DDDF0D',
|
||||
'#7798BF',
|
||||
'#55BF3B',
|
||||
'#DF5353',
|
||||
'#aaeeee',
|
||||
'#ff0066',
|
||||
'#eeaaee',
|
||||
'#55BF3B',
|
||||
'#DF5353',
|
||||
'#7798BF',
|
||||
'#aaeeee',
|
||||
],
|
||||
chart: {
|
||||
backgroundColor: null,
|
||||
|
@ -44,13 +56,13 @@ lichess.chartCommon = function(type) {
|
|||
borderRadius: 0,
|
||||
plotBackgroundColor: null,
|
||||
plotShadow: false,
|
||||
plotBorderWidth: 0
|
||||
plotBorderWidth: 0,
|
||||
},
|
||||
title: {
|
||||
style: {
|
||||
font: Highcharts.makeFont(13),
|
||||
color: text.strong
|
||||
}
|
||||
color: text.strong,
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
gridLineWidth: 0,
|
||||
|
@ -60,18 +72,18 @@ lichess.chartCommon = function(type) {
|
|||
labels: {
|
||||
style: {
|
||||
color: text.weak,
|
||||
fontWeight: 'bold'
|
||||
}
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
},
|
||||
title: {
|
||||
style: {
|
||||
color: text.weak,
|
||||
font: Highcharts.makeFont(12)
|
||||
}
|
||||
font: Highcharts.makeFont(12),
|
||||
},
|
||||
},
|
||||
crosshair: {
|
||||
color: line.weak
|
||||
}
|
||||
color: line.weak,
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
alternateGridColor: null,
|
||||
|
@ -83,31 +95,31 @@ lichess.chartCommon = function(type) {
|
|||
labels: {
|
||||
style: {
|
||||
color: text.weak,
|
||||
fontSize: '10px'
|
||||
}
|
||||
fontSize: '10px',
|
||||
},
|
||||
},
|
||||
title: {
|
||||
style: {
|
||||
color: text.weak,
|
||||
font: Highcharts.makeFont(12)
|
||||
}
|
||||
}
|
||||
font: Highcharts.makeFont(12),
|
||||
},
|
||||
},
|
||||
},
|
||||
legend: {
|
||||
itemStyle: {
|
||||
color: text.strong
|
||||
color: text.strong,
|
||||
},
|
||||
itemHiddenStyle: {
|
||||
color: text.weak
|
||||
}
|
||||
color: text.weak,
|
||||
},
|
||||
},
|
||||
labels: {
|
||||
style: {
|
||||
color: text.strong
|
||||
}
|
||||
color: text.strong,
|
||||
},
|
||||
},
|
||||
lang: {
|
||||
thousandsSep: ''
|
||||
thousandsSep: '',
|
||||
},
|
||||
tooltip: {
|
||||
backgroundColor: {
|
||||
|
@ -115,102 +127,108 @@ lichess.chartCommon = function(type) {
|
|||
x1: 0,
|
||||
y1: 0,
|
||||
x2: 0,
|
||||
y2: 1
|
||||
y2: 1,
|
||||
},
|
||||
stops: light ? [
|
||||
stops: light
|
||||
? [
|
||||
[0, 'rgba(200, 200, 200, .8)'],
|
||||
[1, 'rgba(250, 250, 250, .8)']
|
||||
] : [
|
||||
[0, 'rgba(56, 56, 56, .8)'],
|
||||
[1, 'rgba(16, 16, 16, .8)']
|
||||
[1, 'rgba(250, 250, 250, .8)'],
|
||||
]
|
||||
: [
|
||||
[0, 'rgba(56, 56, 56, .8)'],
|
||||
[1, 'rgba(16, 16, 16, .8)'],
|
||||
],
|
||||
},
|
||||
borderWidth: 0,
|
||||
style: {
|
||||
fontWeight: 'bold',
|
||||
color: text.strong
|
||||
}
|
||||
color: text.strong,
|
||||
},
|
||||
},
|
||||
plotOptions: {
|
||||
series: {
|
||||
shadow: false,
|
||||
nullColor: '#444444'
|
||||
nullColor: '#444444',
|
||||
},
|
||||
line: {
|
||||
dataLabels: {
|
||||
color: text.strong
|
||||
color: text.strong,
|
||||
},
|
||||
marker: {
|
||||
lineColor: text.weak
|
||||
}
|
||||
lineColor: text.weak,
|
||||
},
|
||||
},
|
||||
spline: {
|
||||
marker: {
|
||||
lineColor: text.weak
|
||||
}
|
||||
lineColor: text.weak,
|
||||
},
|
||||
},
|
||||
scatter: {
|
||||
marker: {
|
||||
lineColor: text.weak
|
||||
}
|
||||
lineColor: text.weak,
|
||||
},
|
||||
},
|
||||
candlestick: {
|
||||
lineColor: text.strong
|
||||
}
|
||||
lineColor: text.strong,
|
||||
},
|
||||
},
|
||||
|
||||
// highstock
|
||||
rangeSelector: light ? {} : {
|
||||
rangeSelector: light
|
||||
? {}
|
||||
: {
|
||||
buttonTheme: {
|
||||
fill: '#505053',
|
||||
stroke: '#000000',
|
||||
style: {
|
||||
color: '#CCC'
|
||||
color: '#CCC',
|
||||
},
|
||||
states: {
|
||||
hover: {
|
||||
fill: '#707073',
|
||||
stroke: '#000000',
|
||||
style: {
|
||||
color: 'white'
|
||||
}
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
select: {
|
||||
fill: '#000003',
|
||||
stroke: '#000000',
|
||||
style: {
|
||||
color: 'white'
|
||||
}
|
||||
}
|
||||
}
|
||||
color: 'white',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
inputBoxBorderColor: '#505053',
|
||||
inputStyle: {
|
||||
backgroundColor: '#333',
|
||||
color: 'silver'
|
||||
color: 'silver',
|
||||
},
|
||||
labelStyle: {
|
||||
color: 'silver'
|
||||
}
|
||||
color: 'silver',
|
||||
},
|
||||
},
|
||||
|
||||
navigator: light ? {} : {
|
||||
navigator: light
|
||||
? {}
|
||||
: {
|
||||
handles: {
|
||||
backgroundColor: '#666',
|
||||
borderColor: '#AAA'
|
||||
borderColor: '#AAA',
|
||||
},
|
||||
outlineColor: '#CCC',
|
||||
maskFill: 'rgba(255,255,255,0.1)',
|
||||
series: {
|
||||
color: '#7798BF',
|
||||
lineColor: '#A6C7ED'
|
||||
lineColor: '#A6C7ED',
|
||||
},
|
||||
xAxis: {
|
||||
gridLineColor: '#505053'
|
||||
}
|
||||
}
|
||||
gridLineColor: '#505053',
|
||||
},
|
||||
},
|
||||
};
|
||||
})();
|
||||
Highcharts.setOptions(Highcharts.theme);
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
|
|
@ -8,12 +8,12 @@ lichess.divisionLines = function(div, trans) {
|
|||
align: 'left',
|
||||
y: 0,
|
||||
style: {
|
||||
color: Highcharts.theme.lichess.text.weak
|
||||
}
|
||||
color: Highcharts.theme.lichess.text.weak,
|
||||
},
|
||||
},
|
||||
color: '#639B24',
|
||||
width: 1,
|
||||
value: 0
|
||||
value: 0,
|
||||
});
|
||||
divisionLines.push({
|
||||
label: {
|
||||
|
@ -22,27 +22,28 @@ lichess.divisionLines = function(div, trans) {
|
|||
align: 'left',
|
||||
y: 0,
|
||||
style: {
|
||||
color: Highcharts.theme.lichess.text.weak
|
||||
}
|
||||
color: Highcharts.theme.lichess.text.weak,
|
||||
},
|
||||
},
|
||||
color: '#3093cc',
|
||||
width: div.middle === null ? 0 : 1,
|
||||
value: div.middle
|
||||
value: div.middle,
|
||||
});
|
||||
}
|
||||
if (div.end) divisionLines.push({
|
||||
if (div.end)
|
||||
divisionLines.push({
|
||||
label: {
|
||||
text: trans('endgame'),
|
||||
verticalAlign: 'top',
|
||||
align: 'left',
|
||||
y: 0,
|
||||
style: {
|
||||
color: Highcharts.theme.lichess.text.weak
|
||||
}
|
||||
color: Highcharts.theme.lichess.text.weak,
|
||||
},
|
||||
},
|
||||
color: '#cc9730',
|
||||
width: div.end === null ? 0 : 1,
|
||||
value: div.end
|
||||
value: div.end,
|
||||
});
|
||||
return divisionLines;
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ lichess.movetimeChart = function(data, trans) {
|
|||
|
||||
var series = {
|
||||
white: [],
|
||||
black: []
|
||||
black: [],
|
||||
};
|
||||
|
||||
var tree = data.treeParts;
|
||||
|
@ -32,13 +32,13 @@ lichess.movetimeChart = function(data, trans) {
|
|||
var turn = (ply + 1) >> 1;
|
||||
var color = ply & 1;
|
||||
|
||||
var y = Math.pow(Math.log(.005 * Math.min(time, 12e4) + 3), 2) - logC;
|
||||
var y = Math.pow(Math.log(0.005 * Math.min(time, 12e4) + 3), 2) - logC;
|
||||
max = Math.max(y, max);
|
||||
|
||||
var point = {
|
||||
name: turn + (color ? '. ' : '... ') + san,
|
||||
x: i,
|
||||
y: color ? y : -y
|
||||
y: color ? y : -y,
|
||||
};
|
||||
|
||||
if (blurs[color].shift() === '1') {
|
||||
|
@ -47,7 +47,7 @@ lichess.movetimeChart = function(data, trans) {
|
|||
radius: 3,
|
||||
lineWidth: '1px',
|
||||
lineColor: '#3893E8',
|
||||
fillColor: color ? '#fff' : '#333'
|
||||
fillColor: color ? '#fff' : '#333',
|
||||
};
|
||||
point.name += ' [blur]';
|
||||
}
|
||||
|
@ -56,36 +56,39 @@ lichess.movetimeChart = function(data, trans) {
|
|||
});
|
||||
|
||||
var disabled = {
|
||||
enabled: false
|
||||
enabled: false,
|
||||
};
|
||||
var noText = {
|
||||
text: null
|
||||
text: null,
|
||||
};
|
||||
this.highcharts = Highcharts.chart(this, {
|
||||
credits: disabled,
|
||||
legend: disabled,
|
||||
series: [{
|
||||
series: [
|
||||
{
|
||||
name: 'White',
|
||||
data: series.white
|
||||
}, {
|
||||
data: series.white,
|
||||
},
|
||||
{
|
||||
name: 'Black',
|
||||
data: series.black
|
||||
}],
|
||||
data: series.black,
|
||||
},
|
||||
],
|
||||
chart: {
|
||||
type: 'area',
|
||||
spacing: [2, 0, 2, 0],
|
||||
animation: false
|
||||
animation: false,
|
||||
},
|
||||
tooltip: {
|
||||
formatter: function () {
|
||||
var seconds = data.game.moveCentis[this.x] / 100;
|
||||
if (seconds) seconds = seconds.toFixed(seconds >= 2 ? 1 : 2);
|
||||
return this.point.name + '<br />' + trans('nbSeconds', '<strong>' + seconds + '</strong>');
|
||||
}
|
||||
},
|
||||
},
|
||||
plotOptions: {
|
||||
series: {
|
||||
animation: false
|
||||
animation: false,
|
||||
},
|
||||
area: {
|
||||
fillColor: Highcharts.theme.lichess.area.white,
|
||||
|
@ -98,8 +101,8 @@ lichess.movetimeChart = function(data, trans) {
|
|||
cursor: 'pointer',
|
||||
states: {
|
||||
hover: {
|
||||
lineWidth: 1
|
||||
}
|
||||
lineWidth: 1,
|
||||
},
|
||||
},
|
||||
events: {
|
||||
click: function (event) {
|
||||
|
@ -107,7 +110,7 @@ lichess.movetimeChart = function(data, trans) {
|
|||
event.point.select();
|
||||
lichess.pubsub.emit('analysis.chart.click', event.point.x);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
marker: {
|
||||
radius: 1,
|
||||
|
@ -115,16 +118,16 @@ lichess.movetimeChart = function(data, trans) {
|
|||
hover: {
|
||||
radius: 3,
|
||||
lineColor: '#3893E8',
|
||||
fillColor: '#ffffff'
|
||||
fillColor: '#ffffff',
|
||||
},
|
||||
select: {
|
||||
radius: 4,
|
||||
lineColor: '#3893E8',
|
||||
fillColor: '#ffffff'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fillColor: '#ffffff',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
title: noText,
|
||||
xAxis: {
|
||||
|
@ -132,15 +135,15 @@ lichess.movetimeChart = function(data, trans) {
|
|||
labels: disabled,
|
||||
lineWidth: 0,
|
||||
tickWidth: 0,
|
||||
plotLines: lichess.divisionLines(data.game.division, trans)
|
||||
plotLines: lichess.divisionLines(data.game.division, trans),
|
||||
},
|
||||
yAxis: {
|
||||
title: noText,
|
||||
min: -max,
|
||||
max: max,
|
||||
labels: disabled,
|
||||
gridLineWidth: 0
|
||||
}
|
||||
gridLineWidth: 0,
|
||||
},
|
||||
});
|
||||
});
|
||||
lichess.pubsub.emit('analysis.change.trigger');
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue