prettier: format all files
parent
0be52437ed
commit
1374ea5ee4
|
@ -3,50 +3,50 @@ name: Build assets
|
|||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/workflows/assets.yml'
|
||||
- 'public/**'
|
||||
- 'ui/**'
|
||||
- 'package.json'
|
||||
- 'yarn.lock'
|
||||
- '.github/workflows/assets.yml'
|
||||
- 'public/**'
|
||||
- 'ui/**'
|
||||
- 'package.json'
|
||||
- 'yarn.lock'
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/assets.yml'
|
||||
- 'public/**'
|
||||
- 'ui/**'
|
||||
- 'package.json'
|
||||
- 'yarn.lock'
|
||||
- '.github/workflows/assets.yml'
|
||||
- 'public/**'
|
||||
- 'ui/**'
|
||||
- 'package.json'
|
||||
- 'yarn.lock'
|
||||
|
||||
jobs:
|
||||
assets:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- run: git submodule absorbgitdirs
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: lichess-org/ab
|
||||
ssh-key: ${{ secrets.id_rsa_ab }}
|
||||
ref: master
|
||||
path: ab
|
||||
continue-on-error: true
|
||||
id: ab
|
||||
- run: yarn link --cwd "$GITHUB_WORKSPACE/ab" && yarn link ab --cwd ui/round
|
||||
if: steps.ab.outcome == 'success'
|
||||
- run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
id: yarn-cache
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.yarn-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
|
||||
restore-keys: ${{ runner.os }}-yarn-
|
||||
- run: ./ui/build prod
|
||||
- run: mkdir assets && mv public assets/ && cp LICENSE COPYING.md README.md assets/ && git log -n 1 --pretty=oneline > assets/commit.txt
|
||||
- run: cd assets && tar -cvpJf ../assets.tar.xz . && cd -
|
||||
env:
|
||||
XZ_OPT: '-0'
|
||||
- uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: lila-assets
|
||||
path: assets.tar.xz
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- run: git submodule absorbgitdirs
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: lichess-org/ab
|
||||
ssh-key: ${{ secrets.id_rsa_ab }}
|
||||
ref: master
|
||||
path: ab
|
||||
continue-on-error: true
|
||||
id: ab
|
||||
- run: yarn link --cwd "$GITHUB_WORKSPACE/ab" && yarn link ab --cwd ui/round
|
||||
if: steps.ab.outcome == 'success'
|
||||
- run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
id: yarn-cache
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.yarn-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
|
||||
restore-keys: ${{ runner.os }}-yarn-
|
||||
- run: ./ui/build prod
|
||||
- run: mkdir assets && mv public assets/ && cp LICENSE COPYING.md README.md assets/ && git log -n 1 --pretty=oneline > assets/commit.txt
|
||||
- run: cd assets && tar -cvpJf ../assets.tar.xz . && cd -
|
||||
env:
|
||||
XZ_OPT: '-0'
|
||||
- uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: lila-assets
|
||||
path: assets.tar.xz
|
||||
|
|
|
@ -3,52 +3,52 @@ name: Build server
|
|||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/workflows/server.yml'
|
||||
- 'app/**'
|
||||
- 'conf/**'
|
||||
- 'modules/**'
|
||||
- 'project/**'
|
||||
- 'translation/**'
|
||||
- 'build.sbt'
|
||||
- 'lila'
|
||||
- 'conf/application.conf.default'
|
||||
- '.sbtopts.default'
|
||||
- '.github/workflows/server.yml'
|
||||
- 'app/**'
|
||||
- 'conf/**'
|
||||
- 'modules/**'
|
||||
- 'project/**'
|
||||
- 'translation/**'
|
||||
- 'build.sbt'
|
||||
- 'lila'
|
||||
- 'conf/application.conf.default'
|
||||
- '.sbtopts.default'
|
||||
branches-ignore:
|
||||
- 'l10n_master'
|
||||
- 'l10n_master'
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/server.yml'
|
||||
- 'app/**'
|
||||
- 'conf/**'
|
||||
- 'modules/**'
|
||||
- 'project/**'
|
||||
- 'translation/source/**'
|
||||
- 'build.sbt'
|
||||
- 'lila'
|
||||
- 'conf/application.conf.default'
|
||||
- '.sbtopts.default'
|
||||
- '.github/workflows/server.yml'
|
||||
- 'app/**'
|
||||
- 'conf/**'
|
||||
- 'modules/**'
|
||||
- 'project/**'
|
||||
- 'translation/source/**'
|
||||
- 'build.sbt'
|
||||
- 'lila'
|
||||
- 'conf/application.conf.default'
|
||||
- '.sbtopts.default'
|
||||
|
||||
jobs:
|
||||
openjdk14:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.sbt
|
||||
~/.ivy2/cache
|
||||
key: ${{ runner.os }}-sbt-${{ hashFiles('**/project/build.properties') }}-${{ hashFiles('**/build.sbt') }}-${{ hashFiles('**/project/Dependencies.scala') }}
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 14.0.1
|
||||
- run: TZ=UTC git log -1 --date=iso-strict-local --pretty='format:app.version.commit = "%h"%napp.version.date = "%ad"%napp.version.message = """%s"""%n' | tee conf/version.conf
|
||||
- run: ./lila -Depoll=true "test;stage"
|
||||
- run: cp LICENSE COPYING.md README.md target/universal/stage && git log -n 1 --pretty=oneline > target/universal/stage/commit.txt
|
||||
- run: cd target/universal/stage && tar -cvpJf ../../../lila-3.0.tar.xz . && cd -
|
||||
env:
|
||||
XZ_OPT: '-0'
|
||||
- uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: lila-server
|
||||
path: lila-3.0.tar.xz
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.sbt
|
||||
~/.ivy2/cache
|
||||
key: ${{ runner.os }}-sbt-${{ hashFiles('**/project/build.properties') }}-${{ hashFiles('**/build.sbt') }}-${{ hashFiles('**/project/Dependencies.scala') }}
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 14.0.1
|
||||
- run: TZ=UTC git log -1 --date=iso-strict-local --pretty='format:app.version.commit = "%h"%napp.version.date = "%ad"%napp.version.message = """%s"""%n' | tee conf/version.conf
|
||||
- run: ./lila -Depoll=true "test;stage"
|
||||
- run: cp LICENSE COPYING.md README.md target/universal/stage && git log -n 1 --pretty=oneline > target/universal/stage/commit.txt
|
||||
- run: cd target/universal/stage && tar -cvpJf ../../../lila-3.0.tar.xz . && cd -
|
||||
env:
|
||||
XZ_OPT: '-0'
|
||||
- uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: lila-server
|
||||
path: lila-3.0.tar.xz
|
||||
|
|
|
@ -3,23 +3,23 @@ name: Lint translations
|
|||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/workflows/translations.yml'
|
||||
- 'translation/**'
|
||||
- 'bin/trans-lint.py'
|
||||
- '.github/workflows/translations.yml'
|
||||
- 'translation/**'
|
||||
- 'bin/trans-lint.py'
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/translations.yml'
|
||||
- 'translation/**'
|
||||
- 'bin/trans-lint.py'
|
||||
- '.github/workflows/translations.yml'
|
||||
- 'translation/**'
|
||||
- 'bin/trans-lint.py'
|
||||
|
||||
jobs:
|
||||
translations:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install xmllint
|
||||
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
|
||||
- name: Validate translation files
|
||||
run: xmllint --noout --dtdvalid translation/resources.dtd translation/**/*.xml
|
||||
- name: Lint translation files
|
||||
run: ./bin/trans-lint.py translation/dest/*/*.xml
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install xmllint
|
||||
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
|
||||
- name: Validate translation files
|
||||
run: xmllint --noout --dtdvalid translation/resources.dtd translation/**/*.xml
|
||||
- name: Lint translation files
|
||||
run: ./bin/trans-lint.py translation/dest/*/*.xml
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
31
README.md
31
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,32 +50,28 @@ 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 |
|
||||
| Name | Version | Notes |
|
||||
| ----------------- | ------- | ------------------------------------------------- |
|
||||
| Chromium / Chrome | last 10 | Full support |
|
||||
| Firefox | 61+ | Full support (fastest local analysis since FF 79) |
|
||||
| Opera | 55+ | Reasonable support |
|
||||
| Safari | 11.1+ | Reasonable support |
|
||||
| Edge | 17+ | Reasonable support |
|
||||
| Opera | 55+ | Reasonable support |
|
||||
| Safari | 11.1+ | Reasonable support |
|
||||
| Edge | 17+ | Reasonable support |
|
||||
|
||||
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({
|
||||
$match: {
|
||||
ca: {
|
||||
$gt: ISODate("2013-02-14T14:06:03Z")
|
||||
var result = db.game5.aggregate(
|
||||
{
|
||||
$match: {
|
||||
ca: {
|
||||
$gt: ISODate('2013-02-14T14:06:03Z'),
|
||||
},
|
||||
s: {
|
||||
$gte: 30,
|
||||
},
|
||||
'us.0': {
|
||||
$exists: true,
|
||||
},
|
||||
},
|
||||
s: {
|
||||
$gte: 30
|
||||
},
|
||||
{
|
||||
$unwind: '$us',
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
us: {
|
||||
$ne: '',
|
||||
},
|
||||
},
|
||||
"us.0": {
|
||||
$exists: true
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: '$us',
|
||||
number: {
|
||||
$sum: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
number: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$limit: 10,
|
||||
}
|
||||
}, {
|
||||
$unwind: "$us"
|
||||
}, {
|
||||
$match: {
|
||||
us: {
|
||||
$ne: ""
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$group: {
|
||||
_id: "$us",
|
||||
number: {
|
||||
$sum: 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$sort: {
|
||||
number: -1
|
||||
}
|
||||
}, {
|
||||
$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,13 +78,13 @@ function decodeScore(pp) {
|
|||
return pp == '_' ? null : parseInt(pp);
|
||||
}
|
||||
|
||||
print("Migrating " + max + " analysis");
|
||||
print('Migrating ' + max + ' analysis');
|
||||
|
||||
collection.drop();
|
||||
|
||||
var nb = 0,
|
||||
dat = new Date().getTime() / 1000;
|
||||
gamesToMigrate.forEach(function(a) {
|
||||
gamesToMigrate.forEach(function (a) {
|
||||
var encoded = a.encoded;
|
||||
if (!encoded) return;
|
||||
if (typeof encoded == 'undefined') return;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -15,12 +15,12 @@ function timer(name, f) {
|
|||
}
|
||||
}
|
||||
|
||||
timer('count', function() {
|
||||
timer('count', function () {
|
||||
return coll.count(query) === 1;
|
||||
});
|
||||
timer('find', function() {
|
||||
timer('find', function () {
|
||||
return coll.find(query).limit(1).length() === 1;
|
||||
});
|
||||
timer('findOne', function() {
|
||||
timer('findOne', function () {
|
||||
return coll.findOne(query) !== null;
|
||||
});
|
||||
|
|
|
@ -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},{
|
||||
$unset:{updatedAt:1,createdAt:1},
|
||||
$set:{created:{by:clas.teachers[0],at:clas.createdAt}}
|
||||
});
|
||||
db.clas_clas.find({ createdAt: { $exists: 1 } }).forEach(clas => {
|
||||
db.clas_clas.update(
|
||||
{ _id: clas._id },
|
||||
{
|
||||
$unset: { updatedAt: 1, createdAt: 1 },
|
||||
$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},{
|
||||
$unset:{updatedAt:1,createdAt:1},
|
||||
$set:{created:{by:teacher,at:stu.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 },
|
||||
{
|
||||
$unset: { updatedAt: 1, createdAt: 1 },
|
||||
$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.find({ realName: { $exists: 0 } }).forEach(stu => {
|
||||
db.clas_student.update(
|
||||
{ _id: stu._id },
|
||||
{
|
||||
$set: { realName: stu.userId, notes: '' },
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
db.user2.update({},{$unset:{
|
||||
'settings.chat':1,
|
||||
'settings.sound':1
|
||||
}}, {multi:1});
|
||||
db.user2.update(
|
||||
{},
|
||||
{
|
||||
$unset: {
|
||||
'settings.chat': 1,
|
||||
'settings.sound': 1,
|
||||
},
|
||||
},
|
||||
{ multi: 1 }
|
||||
);
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
var d = new Date();
|
||||
d.setDate(d.getDate()-1);
|
||||
d.setDate(d.getDate() - 1);
|
||||
|
||||
var ids = db.game4.find({t:{$lt:2},ca:{$lt:d}}, {_id:1}).limit(1000).toArray().map(function(g) {
|
||||
return g._id;
|
||||
});
|
||||
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");
|
||||
db.game4.remove({_id:{$in:ids}});
|
||||
print('Remove ' + nb + ' games');
|
||||
db.game4.remove({ _id: { $in: ids } });
|
||||
|
||||
print("Remove " + nb + " pgns");
|
||||
db.pgn.remove({_id:{$in:ids}});
|
||||
print('Remove ' + nb + ' pgns');
|
||||
db.pgn.remove({ _id: { $in: ids } });
|
||||
|
||||
print("Remove " + nb + " bookmarks");
|
||||
db.bookmark.remove({g:{$in:ids}});
|
||||
print('Remove ' + nb + ' bookmarks');
|
||||
db.bookmark.remove({ g: { $in: ids } });
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
var unset;
|
||||
var count = 0;
|
||||
db.game5.find({$or:[{p0:{}},{p1:{}}]}).forEach(g => {
|
||||
db.game5.find({ $or: [{ p0: {} }, { p1: {} }] }).forEach(g => {
|
||||
unset = {};
|
||||
if (g.p0 && !Object.keys(g.p0).length) unset.p0 = true;
|
||||
if (g.p1 && !Object.keys(g.p1).length) unset.p1 = true;
|
||||
if (Object.keys(unset).length) {
|
||||
db.game5.update({_id:g._id},{$unset:unset});
|
||||
db.game5.update({ _id: g._id }, { $unset: unset });
|
||||
count++;
|
||||
if (count % 10000 === 0) print(count);
|
||||
}
|
||||
});
|
||||
print("Done " + count);
|
||||
print('Done ' + count);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
db.coach.find({}).forEach(c => {
|
||||
let u = db.user4.findOne({_id:c._id});
|
||||
u && db.coach.update({_id:c._id},{$set:{languages:u.lang ? [u.lang] : []}});
|
||||
let u = db.user4.findOne({ _id: c._id });
|
||||
u && db.coach.update({ _id: c._id }, { $set: { languages: u.lang ? [u.lang] : [] } });
|
||||
});
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
function toInt(obj) {
|
||||
return function(prop) {
|
||||
return function (prop) {
|
||||
if (typeof obj[prop] != 'undefined' && isNumber(obj[prop])) obj[prop] = NumberInt(obj[prop]);
|
||||
};
|
||||
}
|
||||
// db.config.find({_id:'thibault'}).forEach(function(config) {
|
||||
db.config.find().forEach(function(config) {
|
||||
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]))
|
||||
['friend', 'hook', 'ai'].forEach(function (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) {
|
||||
return NumberInt(n);
|
||||
});
|
||||
['m', 's', 'v'].forEach(function (prop) {
|
||||
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);
|
||||
});
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
[db.config, db.config_anon].forEach(function(coll) {
|
||||
coll.find().forEach(function(o) {
|
||||
[db.config, db.config_anon].forEach(function (coll) {
|
||||
coll.find().forEach(function (o) {
|
||||
var sets = {};
|
||||
var unsets = {};
|
||||
['friend', 'hook', 'ai'].forEach(function(type) {
|
||||
['friend', 'hook', 'ai'].forEach(function (type) {
|
||||
if (!o[type]) return;
|
||||
sets[type + '.tm'] = o[type].k ? NumberInt(1) : NumberInt(0);
|
||||
sets[type + '.d'] = NumberInt(2);
|
||||
unsets[type + '.k'] = true;
|
||||
});
|
||||
coll.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
$set: sets,
|
||||
$unset: unsets
|
||||
});
|
||||
coll.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$set: sets,
|
||||
$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 });
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
var gamesToMigrate = db.game4.find({}, {uids: true, 'p.uid': true});
|
||||
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 = [];
|
||||
game.p.forEach(function(p) {
|
||||
gamesToMigrate.forEach(function (game) {
|
||||
var prev = '',
|
||||
uids = [];
|
||||
game.p.forEach(function (p) {
|
||||
if (p.uid && p.uid != prev) {
|
||||
uids.push(p.uid);
|
||||
prev = 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({
|
||||
plan: {
|
||||
$exists: true
|
||||
db.user4.update(
|
||||
{
|
||||
plan: {
|
||||
$exists: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unset: {
|
||||
plan: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
multi: true,
|
||||
}
|
||||
}, {
|
||||
$unset: {
|
||||
plan: 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
|
||||
}, {
|
||||
$set: {
|
||||
plan: {
|
||||
active: true,
|
||||
months: NumberInt(1),
|
||||
since: donation.date
|
||||
}
|
||||
db.user4.update(
|
||||
{
|
||||
_id: donation.userId,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
plan: {
|
||||
active: true,
|
||||
months: NumberInt(1),
|
||||
since: donation.date,
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
db.donation.find({
|
||||
userId: {
|
||||
'$exists': true
|
||||
}
|
||||
}).sort({
|
||||
date: -1
|
||||
}).forEach(donationToPatron);
|
||||
db.donation
|
||||
.find({
|
||||
userId: {
|
||||
$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',
|
||||
});
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
const colls = ['tournament2'];
|
||||
|
||||
colls.forEach(function(coll) {
|
||||
indexes = db[coll].getIndexes();
|
||||
if(indexes && indexes.length>0) {
|
||||
print("//Indexes for " + coll + ":");
|
||||
}
|
||||
indexes.forEach(function(index) {
|
||||
var options = {};
|
||||
if(index.unique) {
|
||||
options.unique = index.unique;
|
||||
}
|
||||
if(index.sparse) {
|
||||
options.sparse = index.sparse;
|
||||
}
|
||||
if(index.partialFilterExpression) {
|
||||
options.partialFilterExpression = index.partialFilterExpression;
|
||||
}
|
||||
// options.background = true;
|
||||
options = JSON.stringify(options);
|
||||
var key = JSON.stringify(index.key);
|
||||
if(key !== '{"_id":1}') {
|
||||
print('db.' + coll + '.createIndex(' + key + ', ' + options + ');');
|
||||
}
|
||||
});
|
||||
colls.forEach(function (coll) {
|
||||
indexes = db[coll].getIndexes();
|
||||
if (indexes && indexes.length > 0) {
|
||||
print('//Indexes for ' + coll + ':');
|
||||
}
|
||||
indexes.forEach(function (index) {
|
||||
var options = {};
|
||||
if (index.unique) {
|
||||
options.unique = index.unique;
|
||||
}
|
||||
if (index.sparse) {
|
||||
options.sparse = index.sparse;
|
||||
}
|
||||
if (index.partialFilterExpression) {
|
||||
options.partialFilterExpression = index.partialFilterExpression;
|
||||
}
|
||||
// options.background = true;
|
||||
options = JSON.stringify(options);
|
||||
var key = JSON.stringify(index.key);
|
||||
if (key !== '{"_id":1}') {
|
||||
print('db.' + coll + '.createIndex(' + key + ', ' + 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 => {
|
||||
const normalized = gmailNormalize(user.email);
|
||||
const verbatim = user.verbatimEmail || user.email;
|
||||
print(user.username, ': ', verbatim, '->', normalized);
|
||||
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
|
||||
}, {
|
||||
$set: {
|
||||
email: normalized,
|
||||
verbatimEmail: verbatim
|
||||
}
|
||||
db.user4.update(
|
||||
{
|
||||
_id: user._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
email: normalized,
|
||||
verbatimEmail: verbatim,
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,29 +1,37 @@
|
|||
db.f_categ.find({
|
||||
pos: {
|
||||
$type: 1
|
||||
}
|
||||
}).forEach(function(o) {
|
||||
print(o.name);
|
||||
db.f_categ.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
$unset: {
|
||||
pos: 1,
|
||||
nbTopics: 1,
|
||||
nbPosts: 1,
|
||||
nbTopicsTroll: 1,
|
||||
nbPostsTroll: 1
|
||||
}
|
||||
db.f_categ
|
||||
.find({
|
||||
pos: {
|
||||
$type: 1,
|
||||
},
|
||||
})
|
||||
.forEach(function (o) {
|
||||
print(o.name);
|
||||
db.f_categ.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$unset: {
|
||||
pos: 1,
|
||||
nbTopics: 1,
|
||||
nbPosts: 1,
|
||||
nbTopicsTroll: 1,
|
||||
nbPostsTroll: 1,
|
||||
},
|
||||
}
|
||||
);
|
||||
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),
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
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)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var games = db.game5;
|
||||
db.analysis2.find({},{_id:true}).forEach(function(analysis) {
|
||||
games.update({_id: analysis._id},{$set:{an:true}});
|
||||
db.analysis2.find({}, { _id: true }).forEach(function (analysis) {
|
||||
games.update({ _id: analysis._id }, { $set: { an: true } });
|
||||
});
|
||||
|
|
|
@ -9,7 +9,8 @@ function daysAgo(days) {
|
|||
}
|
||||
|
||||
for (var i = daysBack; i >= 0; i--) {
|
||||
var from = daysAgo(i + 1), to = daysAgo(i);
|
||||
var games = db.game5.count({ca:{$gte: from, $lt: to}});
|
||||
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,6 @@
|
|||
db.game5.find({so:7, 'pgni.user': {$exists: true}}).forEach(function(g) {
|
||||
db.game5.find({ so: 7, 'pgni.user': { $exists: true } }).forEach(function (g) {
|
||||
delete g.ua;
|
||||
delete g.tv;
|
||||
g.pgni.ca = g.ca;
|
||||
db.game5.update({_id:g._id},{$set:{'pgni.ca': g.ca},$unset:{ua:true,tv:true}});
|
||||
db.game5.update({ _id: g._id }, { $set: { 'pgni.ca': g.ca }, $unset: { ua: true, tv: true } });
|
||||
});
|
||||
|
|
|
@ -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,49 +55,52 @@ 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}`);
|
||||
}
|
||||
|
||||
const indexes = [
|
||||
{users:1},
|
||||
{winner:1},
|
||||
{loser:1},
|
||||
{winColor: 1},
|
||||
{avgRating: 1},
|
||||
{source: 1},
|
||||
{variants: 1},
|
||||
{mode: 1},
|
||||
{turns: 1},
|
||||
{minutes: 1},
|
||||
{'clock.init':1},
|
||||
{'clock.inc': 1},
|
||||
{result: 1},
|
||||
{date: 1},
|
||||
{analysed: 1}
|
||||
{ users: 1 },
|
||||
{ winner: 1 },
|
||||
{ loser: 1 },
|
||||
{ winColor: 1 },
|
||||
{ avgRating: 1 },
|
||||
{ source: 1 },
|
||||
{ variants: 1 },
|
||||
{ mode: 1 },
|
||||
{ turns: 1 },
|
||||
{ minutes: 1 },
|
||||
{ 'clock.init': 1 },
|
||||
{ 'clock.inc': 1 },
|
||||
{ result: 1 },
|
||||
{ date: 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({
|
||||
avgRating: { $gt: 1000 },
|
||||
turns: { $lt: 250 },
|
||||
'clock.init': { $gt: 1 },
|
||||
minutes: { $gt: 2, $lt: 150 },
|
||||
}).sort({
|
||||
date: -1
|
||||
}).limit(20).explain('executionStats');
|
||||
|
||||
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');
|
||||
|
||||
/*
|
||||
"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,18 +39,22 @@ 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;
|
||||
var dat = new Date().getTime() / 1000;
|
||||
var finishedPlayerFieldsToRemove = ['previousMoveTs', 'lastDrawOffer', 'isOfferingDraw', 'isProposingTakeback'];
|
||||
|
||||
gamesToMigrate.forEach(function(g) {
|
||||
gamesToMigrate.forEach(function (g) {
|
||||
cleanOrRename(g, 'castles', 'cs');
|
||||
if (g.cc === 'white') {
|
||||
if (g.cc === 'white') {
|
||||
delete g.cc;
|
||||
} else {
|
||||
g.cc = false;
|
||||
|
@ -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 {
|
||||
|
@ -94,7 +98,7 @@ gamesToMigrate.forEach(function(g) {
|
|||
}
|
||||
}
|
||||
rename(g, 'players', 'p');
|
||||
g.p.forEach(function(p) {
|
||||
g.p.forEach(function (p) {
|
||||
delete p.c;
|
||||
map(p, 'ps', removeSpace);
|
||||
if (finishedOrAborted(g) && typeof p.blurs !== 'undefined' && p.blurs < 7) {
|
||||
|
@ -113,8 +117,8 @@ gamesToMigrate.forEach(function(g) {
|
|||
pgn = g.pgn;
|
||||
delete g.pgn;
|
||||
collection.insert(g);
|
||||
if (pgn !== null && pgn !== "") {
|
||||
pgnCollection.insert({_id: g._id, p: pgn});
|
||||
if (pgn !== null && pgn !== '') {
|
||||
pgnCollection.insert({ _id: g._id, p: pgn });
|
||||
}
|
||||
++it;
|
||||
if (it % batchSize == 0) {
|
||||
|
@ -122,16 +126,16 @@ 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");
|
||||
collection.ensureIndex({s: 1});
|
||||
collection.ensureIndex({uids: 1}, {sparse: 1});
|
||||
collection.ensureIndex({wid: 1}, {sparse: 1});
|
||||
collection.ensureIndex({ca: -1});
|
||||
collection.ensureIndex({uids: 1, ca: -1});
|
||||
collection.ensureIndex({bm: 1}, {sparse: 1});
|
||||
print('Building indexes');
|
||||
collection.ensureIndex({ s: 1 });
|
||||
collection.ensureIndex({ uids: 1 }, { sparse: 1 });
|
||||
collection.ensureIndex({ wid: 1 }, { sparse: 1 });
|
||||
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 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") {
|
||||
gamesToMigrate.forEach(function (g) {
|
||||
g.p.forEach(function (p) {
|
||||
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,16 +45,16 @@ 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");
|
||||
collection.ensureIndex({s: 1});
|
||||
collection.ensureIndex({uids: 1}, {sparse: 1});
|
||||
collection.ensureIndex({wid: 1}, {sparse: 1});
|
||||
collection.ensureIndex({ca: -1});
|
||||
collection.ensureIndex({uids: 1, ca: -1});
|
||||
collection.ensureIndex({bm: 1}, {sparse: 1});
|
||||
print('Building indexes');
|
||||
collection.ensureIndex({ s: 1 });
|
||||
collection.ensureIndex({ uids: 1 }, { sparse: 1 });
|
||||
collection.ensureIndex({ wid: 1 }, { sparse: 1 });
|
||||
collection.ensureIndex({ ca: -1 });
|
||||
collection.ensureIndex({ uids: 1, ca: -1 });
|
||||
collection.ensureIndex({ bm: 1 }, { sparse: 1 });
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
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;
|
||||
|
||||
userIds.forEach(id => {
|
||||
var user = db.user4.findOne({_id:id});
|
||||
var user = db.user4.findOne({ _id: id });
|
||||
perfTypes.forEach(pt => {
|
||||
if (user && (!user.perfs[pt] || !user.perfs[pt].nb))
|
||||
db.user4.update({_id:id},{$set:{['perfs.' + pt]: perf}});
|
||||
db.user4.update({ _id: id }, { $set: { ['perfs.' + pt]: perf } });
|
||||
});
|
||||
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});
|
||||
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 }
|
||||
);
|
||||
});
|
||||
|
|
|
@ -3,20 +3,21 @@ 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();
|
||||
|
||||
var game;
|
||||
historyToMigrate.forEach(function(h) {
|
||||
var h2 = {_id: h._id, entries: []};
|
||||
historyToMigrate.forEach(function (h) {
|
||||
var h2 = { _id: h._id, entries: [] };
|
||||
for (ts in h.entries) {
|
||||
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);
|
||||
|
@ -24,14 +25,13 @@ historyToMigrate.forEach(function(h) {
|
|||
}
|
||||
h2.entries.push(e2);
|
||||
}
|
||||
collection.update({_id: h2._id}, {$set: h2}, {upsert: true});
|
||||
collection.update({ _id: h2._id }, { $set: h2 }, { upsert: true });
|
||||
++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,43 +1,40 @@
|
|||
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();
|
||||
|
||||
function flush(cache) {
|
||||
for(uid in cache) {
|
||||
collection.update({_id: uid}, {$pushAll: { entries: cache[uid] }}, {upsert: true});
|
||||
for (uid in cache) {
|
||||
collection.update({ _id: uid }, { $pushAll: { entries: cache[uid] } }, { upsert: true });
|
||||
}
|
||||
}
|
||||
|
||||
var cache = {};
|
||||
games.forEach(function(game) {
|
||||
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);
|
||||
} catch (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) {
|
||||
[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
|
||||
}, {
|
||||
$push: {
|
||||
'filter.v': NumberInt(8)
|
||||
coll.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$push: {
|
||||
'filter.v': NumberInt(8),
|
||||
},
|
||||
}
|
||||
});
|
||||
};
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
db.trophy.drop();
|
||||
db.trophy.ensureIndex({user: 1});
|
||||
db.trophy.ensureIndex({ user: 1 });
|
||||
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',
|
||||
|
|
|
@ -1,21 +1,27 @@
|
|||
var id = 'winter17';
|
||||
var copyFromId = 'autumn17';
|
||||
|
||||
var t = db.tournament2.findOne({_id:copyFromId});
|
||||
var t = db.tournament2.findOne({ _id: copyFromId });
|
||||
|
||||
// overrides
|
||||
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!";
|
||||
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!';
|
||||
|
||||
// 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,58 +1,61 @@
|
|||
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({
|
||||
'profile.location':'montreal',
|
||||
enabled:true,
|
||||
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;
|
||||
var threadId = Math.random().toString(36).substring(2, 10);
|
||||
db.notify.insert({
|
||||
_id: Math.random().toString(36).substring(2, 10),
|
||||
notifies: user._id,
|
||||
content: {
|
||||
type: 'privateMessage',
|
||||
senderId: sender,
|
||||
thread: {
|
||||
id: threadId,
|
||||
name: threadName
|
||||
db.user4
|
||||
.find({
|
||||
'profile.location': 'montreal',
|
||||
enabled: true,
|
||||
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;
|
||||
var threadId = Math.random().toString(36).substring(2, 10);
|
||||
db.notify.insert({
|
||||
_id: Math.random().toString(36).substring(2, 10),
|
||||
notifies: user._id,
|
||||
content: {
|
||||
type: 'privateMessage',
|
||||
senderId: sender,
|
||||
thread: {
|
||||
id: threadId,
|
||||
name: threadName,
|
||||
},
|
||||
text: threadName,
|
||||
},
|
||||
text: threadName
|
||||
},
|
||||
read: false,
|
||||
createdAt: new Date()
|
||||
read: false,
|
||||
createdAt: new Date(),
|
||||
});
|
||||
print(user.username);
|
||||
db.m_thread.insert({
|
||||
_id: threadId,
|
||||
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(),
|
||||
},
|
||||
],
|
||||
creatorId: sender,
|
||||
invitedId: user._id,
|
||||
visibleByUserIds: ['lichess', user._id],
|
||||
mod: true,
|
||||
});
|
||||
sent++;
|
||||
});
|
||||
print(user.username);
|
||||
db.m_thread.insert({
|
||||
_id: threadId,
|
||||
"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()
|
||||
}
|
||||
],
|
||||
"creatorId": sender,
|
||||
"invitedId": user._id,
|
||||
"visibleByUserIds": [
|
||||
"lichess",
|
||||
user._id
|
||||
],
|
||||
"mod": true
|
||||
});
|
||||
sent++;
|
||||
});
|
||||
|
||||
print('Sent ' + sent);
|
||||
|
|
|
@ -2,12 +2,12 @@ const tid = 'a/b';
|
|||
const renderDate = date => `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()}`;
|
||||
|
||||
db.msg_msg
|
||||
.find({tid:tid})
|
||||
.sort({date:1})
|
||||
.find({ tid: tid })
|
||||
.sort({ date: 1 })
|
||||
.forEach(m => {
|
||||
print(`${renderDate(m.date)} ${m.user}`);
|
||||
print(m.text);
|
||||
print('');
|
||||
print('-----------------------------------------------------------------------------');
|
||||
print('');
|
||||
});
|
||||
print(`${renderDate(m.date)} ${m.user}`);
|
||||
print(m.text);
|
||||
print('');
|
||||
print('-----------------------------------------------------------------------------');
|
||||
print('');
|
||||
});
|
||||
|
|
|
@ -2,81 +2,87 @@ db.msg_msg.drop();
|
|||
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_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 });
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
print("Delete old notifications");
|
||||
db.notify.remove({'content.type':'privateMessage'});
|
||||
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({
|
||||
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 => {
|
||||
if (t.creatorId == t.invitedId) return;
|
||||
t.visibleByUserIds.sort();
|
||||
db.m_thread_sorted.insert(t);
|
||||
});
|
||||
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 => {
|
||||
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('/');
|
||||
|
||||
let userIds = o.threads[0].visibleByUserIds;
|
||||
userIds.sort();
|
||||
let threadId = userIds.join('/');
|
||||
let msgs = [];
|
||||
|
||||
let msgs = [];
|
||||
|
||||
o.threads.forEach(t => {
|
||||
t.posts.forEach(p => {
|
||||
if (o.creatorId == 'lichess' && isOld(p.createdAt)) return;
|
||||
msgs.push({
|
||||
_id: p.id,
|
||||
tid: threadId,
|
||||
text: p.text,
|
||||
user: p.isByCreator ? t.creatorId : t.invitedId,
|
||||
date: p.createdAt
|
||||
o.threads.forEach(t => {
|
||||
t.posts.forEach(p => {
|
||||
if (o.creatorId == 'lichess' && isOld(p.createdAt)) return;
|
||||
msgs.push({
|
||||
_id: p.id,
|
||||
tid: threadId,
|
||||
text: p.text,
|
||||
user: p.isByCreator ? t.creatorId : t.invitedId,
|
||||
date: p.createdAt,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (!msgs.length) return;
|
||||
|
||||
msgs.sort((a, b) => new Date(a.date) - new Date(b.date));
|
||||
|
||||
let last = msgs[msgs.length - 1];
|
||||
|
||||
let thread = {
|
||||
_id: threadId,
|
||||
users: userIds,
|
||||
lastMsg: {
|
||||
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),
|
||||
},
|
||||
};
|
||||
|
||||
db.msg_msg.insertMany(msgs, { ordered: false });
|
||||
try {
|
||||
db.msg_thread.insert(thread);
|
||||
} catch (e) {}
|
||||
});
|
||||
|
||||
if (!msgs.length) return;
|
||||
|
||||
msgs.sort((a,b) => new Date(a.date) - new Date(b.date));
|
||||
|
||||
let last = msgs[msgs.length - 1];
|
||||
|
||||
let thread = {
|
||||
_id: threadId,
|
||||
users: userIds,
|
||||
lastMsg: {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
db.msg_msg.insertMany(msgs, {ordered: false});
|
||||
try {
|
||||
db.msg_thread.insert(thread);
|
||||
} catch(e) {}
|
||||
});
|
||||
|
||||
makeIndexes();
|
||||
|
||||
function isOld(date) {
|
||||
|
|
|
@ -1,22 +1,36 @@
|
|||
db.user4.find({
|
||||
enabled: true,
|
||||
roles:{$in:['ROLE_SUPER_ADMIN', 'ROLE_ADMIN','ROLE_HUNTER','ROLE_SEE_REPORT']}
|
||||
},{_id:1, plan:1}).forEach(user => {
|
||||
db.user4
|
||||
.find(
|
||||
{
|
||||
enabled: true,
|
||||
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 || {};
|
||||
|
||||
var userId = user._id;
|
||||
var prev = user.plan || {};
|
||||
print(userId, !!prev.active);
|
||||
|
||||
print(userId, !!prev.active);
|
||||
db.user4.update(
|
||||
{ _id: userId },
|
||||
{
|
||||
$set: {
|
||||
plan: {
|
||||
months: NumberInt(prev.months || 1),
|
||||
active: true,
|
||||
since: prev.since || new Date(),
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
db.user4.update({_id:userId},{$set:{plan:{
|
||||
months:NumberInt(prev.months || 1),
|
||||
active:true,
|
||||
since: prev.since || new Date()
|
||||
}}})
|
||||
|
||||
db.plan_patron.update({_id:userId}, {
|
||||
lastLevelUp: new Date(),
|
||||
lifetime: true
|
||||
}, {upsert:true});
|
||||
|
||||
});
|
||||
db.plan_patron.update(
|
||||
{ _id: userId },
|
||||
{
|
||||
lastLevelUp: new Date(),
|
||||
lifetime: true,
|
||||
},
|
||||
{ upsert: true }
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
var userId = 'shork'.toLowerCase();
|
||||
|
||||
var prev = db.user4.findOne({_id:userId}).plan;
|
||||
var prev = db.user4.findOne({ _id: userId }).plan;
|
||||
|
||||
db.user4.update({_id:userId},{$set:{plan:{
|
||||
months:NumberInt(prev.months || 1),
|
||||
active:true,
|
||||
since: prev.since || new Date()
|
||||
}}})
|
||||
db.user4.update(
|
||||
{ _id: userId },
|
||||
{
|
||||
$set: {
|
||||
plan: {
|
||||
months: NumberInt(prev.months || 1),
|
||||
active: true,
|
||||
since: prev.since || new Date(),
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
db.plan_patron.update({_id:userId}, {
|
||||
lastLevelUp: new Date(),
|
||||
lifetime: true
|
||||
}, {upsert:true});
|
||||
db.plan_patron.update(
|
||||
{ _id: userId },
|
||||
{
|
||||
lastLevelUp: new Date(),
|
||||
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");
|
||||
db.user2.update({},{$rename:{isChatBan:'troll'}}, {multi:true});
|
||||
print('rename user.isChatBan -> user.troll');
|
||||
db.user2.update({}, { $rename: { isChatBan: 'troll' } }, { multi: true });
|
||||
|
||||
print("add troll fields to the forum topics")
|
||||
db.f_topic.find().forEach(function(topic) {
|
||||
db.f_topic.update({'_id': topic['_id']}, { $set: {
|
||||
troll: false,
|
||||
updatedAtTroll: topic['updatedAt'],
|
||||
nbPostsTroll: topic['nbPosts'],
|
||||
lastPostIdTroll: topic['lastPostId']
|
||||
}});
|
||||
print('add troll fields to the forum topics');
|
||||
db.f_topic.find().forEach(function (topic) {
|
||||
db.f_topic.update(
|
||||
{ _id: topic['_id'] },
|
||||
{
|
||||
$set: {
|
||||
troll: false,
|
||||
updatedAtTroll: topic['updatedAt'],
|
||||
nbPostsTroll: topic['nbPosts'],
|
||||
lastPostIdTroll: topic['lastPostId'],
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
print("add troll fields to the forum categs")
|
||||
db.f_categ.find().forEach(function(categ) {
|
||||
db.f_categ.update({'_id': categ['_id']}, { $set: {
|
||||
nbTopicsTroll: categ['nbTopics'],
|
||||
nbPostsTroll: categ['nbPosts'],
|
||||
lastPostIdTroll: categ['lastPostId']
|
||||
}});
|
||||
print('add troll fields to the forum categs');
|
||||
db.f_categ.find().forEach(function (categ) {
|
||||
db.f_categ.update(
|
||||
{ _id: categ['_id'] },
|
||||
{
|
||||
$set: {
|
||||
nbTopicsTroll: categ['nbTopics'],
|
||||
nbPostsTroll: categ['nbPosts'],
|
||||
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");
|
||||
db.f_post.update({},{$set:{troll:false}}, {multi:true});
|
||||
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");
|
||||
['settings.chat', 'settings.sound'].forEach(function(name) {
|
||||
[true, false].forEach(function(value) {
|
||||
var sel = {}
|
||||
print('user.settings.{chat,sound} should be a string');
|
||||
['settings.chat', 'settings.sound'].forEach(function (name) {
|
||||
[true, false].forEach(function (value) {
|
||||
var sel = {};
|
||||
sel[name] = value;
|
||||
db.user2.find(sel).forEach(function(user) {
|
||||
var up = {}
|
||||
db.user2.find(sel).forEach(function (user) {
|
||||
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.timeline_entry.ensureIndex({user:1, date: -1});
|
||||
db.timeline_entry.ensureIndex({type:1, date: -1});
|
||||
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_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_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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
print("Building indexes");
|
||||
db.f_post.ensureIndex({categId: 1});
|
||||
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({
|
||||
studyId: {
|
||||
$in: studyIds
|
||||
}
|
||||
}).forEach(function(chapter) {
|
||||
var chapters = db.study_chapter
|
||||
.find({
|
||||
studyId: {
|
||||
$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,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
'root.f': fixed,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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
|
||||
}, {
|
||||
$set: {
|
||||
'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
|
||||
}, {
|
||||
$set: {
|
||||
'root.p': NumberInt(ply)
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
var ply = makePly(fixed);
|
||||
if (chapter.root.p != ply) {
|
||||
print('Fix chapter root ply ' + chapter._id);
|
||||
db.study_chapter.update(
|
||||
{
|
||||
_id: chapter._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
'root.p': NumberInt(ply),
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
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});
|
||||
var study = db.study.findOne({ _id: id });
|
||||
print(`${study._id} ${study.name}`);
|
||||
db.study_chapter.find({
|
||||
studyId:id,
|
||||
'root.co': {$exists:1}
|
||||
}).forEach(chapter => {
|
||||
print(' - ' + chapter._id + ' ' + chapter.name);
|
||||
db.study_chapter.update(
|
||||
{_id:chapter._id},
|
||||
{$set:{description: chapter.root.co[0].text},$unset:{'root.co':1}}
|
||||
);
|
||||
});
|
||||
db.study_chapter
|
||||
.find({
|
||||
studyId: id,
|
||||
'root.co': { $exists: 1 },
|
||||
})
|
||||
.forEach(chapter => {
|
||||
print(' - ' + chapter._id + ' ' + chapter.name);
|
||||
db.study_chapter.update(
|
||||
{ _id: chapter._id },
|
||||
{ $set: { description: chapter.root.co[0].text }, $unset: { 'root.co': 1 } }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
db.pref.find({dark:{$exists:1}}, {dark:1,transp:1}).forEach(p => {
|
||||
db.pref.find({ dark: { $exists: 1 } }, { dark: 1, transp: 1 }).forEach(p => {
|
||||
const bg = p.dark ? (p.transp ? 400 : 200) : 100;
|
||||
db.pref.update({_id: p._id}, {$set:{bg: NumberInt(bg)},$unset:{dark:1,transp:1}});
|
||||
db.pref.update({ _id: p._id }, { $set: { bg: NumberInt(bg) }, $unset: { dark: 1, transp: 1 } });
|
||||
});
|
||||
|
|
|
@ -1,23 +1,30 @@
|
|||
var props = ['animation', 'autoQueen', 'autoThreefold', 'challenge', 'coordColor', 'takeback'];
|
||||
db.pref.find().forEach(function(p) {
|
||||
var set = {}, unset = {};
|
||||
props.forEach(function(prop) {
|
||||
db.pref.find().forEach(function (p) {
|
||||
var set = {},
|
||||
unset = {};
|
||||
props.forEach(function (prop) {
|
||||
if (typeof p[prop] !== 'undefined') {
|
||||
unset[prop] = true;
|
||||
set[prop] = new NumberInt(p[prop]);
|
||||
}
|
||||
});
|
||||
// must unset first, or update does not happen D:
|
||||
db.pref.update({
|
||||
_id: p._id,
|
||||
}, {
|
||||
'$unset': set
|
||||
});
|
||||
db.pref.update({
|
||||
_id: p._id,
|
||||
}, {
|
||||
'$set': set
|
||||
});
|
||||
db.pref.update(
|
||||
{
|
||||
_id: p._id,
|
||||
},
|
||||
{
|
||||
$unset: set,
|
||||
}
|
||||
);
|
||||
db.pref.update(
|
||||
{
|
||||
_id: p._id,
|
||||
},
|
||||
{
|
||||
$set: set,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -16,30 +16,35 @@ function depthOf(obj) {
|
|||
return level;
|
||||
}
|
||||
|
||||
puzzles.find({
|
||||
"mate": true,
|
||||
"_id": {
|
||||
"$gt": 60120
|
||||
},
|
||||
'vote.sum': {
|
||||
'$gt': -8000
|
||||
}
|
||||
}).forEach(function(p) {
|
||||
var depth = depthOf(p);
|
||||
if (depth % 2 === 1) {
|
||||
count++;
|
||||
puzzles.update({
|
||||
_id: p._id
|
||||
}, {
|
||||
$set: {
|
||||
vote: {
|
||||
up: NumberInt(0),
|
||||
down: NumberInt(9000),
|
||||
sum: NumberInt(-9000)
|
||||
puzzles
|
||||
.find({
|
||||
mate: true,
|
||||
_id: {
|
||||
$gt: 60120,
|
||||
},
|
||||
'vote.sum': {
|
||||
$gt: -8000,
|
||||
},
|
||||
})
|
||||
.forEach(function (p) {
|
||||
var depth = depthOf(p);
|
||||
if (depth % 2 === 1) {
|
||||
count++;
|
||||
puzzles.update(
|
||||
{
|
||||
_id: p._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
vote: {
|
||||
up: NumberInt(0),
|
||||
down: NumberInt(9000),
|
||||
sum: NumberInt(-9000),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
print(p._id);
|
||||
}
|
||||
});
|
||||
print("Disabled " + count + " puzzles");
|
||||
);
|
||||
print(p._id);
|
||||
}
|
||||
});
|
||||
print('Disabled ' + count + ' puzzles');
|
||||
|
|
|
@ -6,22 +6,27 @@ function fullMoveNumber(p) {
|
|||
|
||||
function changeFenMoveNumber(fen, n) {
|
||||
parts = fen.split(' ');
|
||||
parts[parts.length-1] = n;
|
||||
parts[parts.length - 1] = n;
|
||||
return parts.join(' ');
|
||||
}
|
||||
|
||||
puzzles.find({
|
||||
"_id": {
|
||||
"$lt": 60121
|
||||
}
|
||||
}).forEach(function(p) {
|
||||
var newMoveNumber = fullMoveNumber(p);
|
||||
var newFen = changeFenMoveNumber(p.fen, newMoveNumber);
|
||||
puzzles.update({
|
||||
_id: p._id
|
||||
}, {
|
||||
$set: {
|
||||
fen: newFen
|
||||
}
|
||||
puzzles
|
||||
.find({
|
||||
_id: {
|
||||
$lt: 60121,
|
||||
},
|
||||
})
|
||||
.forEach(function (p) {
|
||||
var newMoveNumber = fullMoveNumber(p);
|
||||
var newFen = changeFenMoveNumber(p.fen, newMoveNumber);
|
||||
puzzles.update(
|
||||
{
|
||||
_id: p._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
fen: newFen,
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
var id = 14065;
|
||||
db.puzzle.update({_id:id},{$set:{perf:db.puzzle.findOne({_id:60002}).perf}});
|
||||
db.puzzle.update({ _id: id }, { $set: { perf: db.puzzle.findOne({ _id: 60002 }).perf } });
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
db.puzzle.find({tags: {$exists:true}}).forEach(function(o) {
|
||||
db.puzzle.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
$set: {
|
||||
mate: o.tags.indexOf("forced mate") !== -1
|
||||
db.puzzle.find({ tags: { $exists: true } }).forEach(function (o) {
|
||||
db.puzzle.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
$unset: {
|
||||
tags: true
|
||||
{
|
||||
$set: {
|
||||
mate: o.tags.indexOf('forced mate') !== -1,
|
||||
},
|
||||
$unset: {
|
||||
tags: true,
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -2,21 +2,26 @@ var puzzles = db.puzzle;
|
|||
|
||||
modified = 0;
|
||||
|
||||
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)
|
||||
},
|
||||
$unset: {
|
||||
'vote.sum': true
|
||||
}
|
||||
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),
|
||||
},
|
||||
$unset: {
|
||||
'vote.sum': true,
|
||||
},
|
||||
}
|
||||
);
|
||||
modified += 1;
|
||||
});
|
||||
modified += 1;
|
||||
});
|
||||
|
||||
print(modified);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// for puzzle v2
|
||||
|
||||
db.puzzle2_path.createIndex({min: 1, max: -1});
|
||||
db.puzzle2_path.createIndex({ min: 1, max: -1 });
|
||||
|
||||
db.puzzle2_round.createIndex({p: 1}, {partialFilterExpression:{t:{$exists:true}}});
|
||||
db.puzzle2_round.createIndex({u:1,d:-1},{partialFilterExpression:{u:{$exists:1}}});
|
||||
db.puzzle2_round.createIndex({ p: 1 }, { partialFilterExpression: { t: { $exists: true } } });
|
||||
db.puzzle2_round.createIndex({ u: 1, d: -1 }, { partialFilterExpression: { u: { $exists: 1 } } });
|
||||
|
||||
db.puzzle2_puzzle.createIndex({day:1}, {partialFilterExpression:{day:{$exists:true}}});
|
||||
db.puzzle2_puzzle.createIndex({ day: 1 }, { partialFilterExpression: { day: { $exists: true } } });
|
||||
|
|
|
@ -1,36 +1,46 @@
|
|||
db.puzzle.find({
|
||||
perf: {
|
||||
$exists: false
|
||||
}
|
||||
}).forEach(function(o) {
|
||||
db.puzzle.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
$set: {
|
||||
perf: {
|
||||
gl: o.rating,
|
||||
nb: NumberInt(0)
|
||||
}
|
||||
db.puzzle
|
||||
.find({
|
||||
perf: {
|
||||
$exists: false,
|
||||
},
|
||||
$unset: {
|
||||
rating: true
|
||||
}
|
||||
});
|
||||
});
|
||||
db.puzzle.find({
|
||||
'vote.up': {
|
||||
$exists: false
|
||||
}
|
||||
}).forEach(function(o) {
|
||||
db.puzzle.update({
|
||||
_id: o._id
|
||||
}, {
|
||||
$set: {
|
||||
vote: {
|
||||
up: NumberInt(0),
|
||||
down: NumberInt(0),
|
||||
sum: NumberInt(0)
|
||||
})
|
||||
.forEach(function (o) {
|
||||
db.puzzle.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
perf: {
|
||||
gl: o.rating,
|
||||
nb: NumberInt(0),
|
||||
},
|
||||
},
|
||||
$unset: {
|
||||
rating: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
db.puzzle
|
||||
.find({
|
||||
'vote.up': {
|
||||
$exists: false,
|
||||
},
|
||||
})
|
||||
.forEach(function (o) {
|
||||
db.puzzle.update(
|
||||
{
|
||||
_id: o._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
vote: {
|
||||
up: NumberInt(0),
|
||||
down: NumberInt(0),
|
||||
sum: NumberInt(0),
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,39 +1,48 @@
|
|||
// 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) {
|
||||
Number.prototype.pad = function (size) {
|
||||
var s = String(this);
|
||||
while (s.length < (size || 2)) {s = "0" + s;}
|
||||
return s;
|
||||
}
|
||||
|
||||
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;
|
||||
m += r.r;
|
||||
o = {
|
||||
_id: `${r.u}:${(r.p - shift).pad(5)}`,
|
||||
a: r.a,
|
||||
m: NumberInt(m)
|
||||
};
|
||||
var win = !!(m >>> 31);
|
||||
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";
|
||||
db.puzzle_round2.insert(o);
|
||||
} catch(e) {
|
||||
print(e, r._id);
|
||||
while (s.length < (size || 2)) {
|
||||
s = '0' + s;
|
||||
}
|
||||
n++;
|
||||
if (n % 10000 === 0) print(`${n}/${total}`);
|
||||
});
|
||||
return s;
|
||||
};
|
||||
|
||||
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;
|
||||
m += r.r;
|
||||
o = {
|
||||
_id: `${r.u}:${(r.p - shift).pad(5)}`,
|
||||
a: r.a,
|
||||
m: NumberInt(m),
|
||||
};
|
||||
var win = !!(m >>> 31);
|
||||
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';
|
||||
db.puzzle_round2.insert(o);
|
||||
} catch (e) {
|
||||
print(e, r._id);
|
||||
}
|
||||
n++;
|
||||
if (n % 10000 === 0) print(`${n}/${total}`);
|
||||
});
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
var coll = db.puzzle;
|
||||
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);
|
||||
p._id = NumberInt(nextId);
|
||||
print(p.salvaged + ' -> ' + p._id);
|
||||
coll.insert(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);
|
||||
p._id = NumberInt(nextId);
|
||||
print(p.salvaged + ' -> ' + p._id);
|
||||
coll.insert(p);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,54 +1,86 @@
|
|||
db.puzzle2_round.aggregate([{
|
||||
$match: {
|
||||
v: {
|
||||
$exists: 1
|
||||
db.puzzle2_round
|
||||
.aggregate(
|
||||
[
|
||||
{
|
||||
$match: {
|
||||
v: {
|
||||
$exists: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: {
|
||||
$arrayElemAt: [
|
||||
{
|
||||
$split: ['$_id', ':'],
|
||||
},
|
||||
1,
|
||||
],
|
||||
},
|
||||
vu: {
|
||||
$sum: {
|
||||
$cond: [
|
||||
{
|
||||
$gt: ['$v', 0],
|
||||
},
|
||||
'$v',
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
vd: {
|
||||
$sum: {
|
||||
$cond: [
|
||||
{
|
||||
$lt: ['$v', 0],
|
||||
},
|
||||
{
|
||||
$subtract: [0, '$v'],
|
||||
},
|
||||
0,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 1,
|
||||
vu: 1,
|
||||
vd: 1,
|
||||
v: {
|
||||
$divide: [
|
||||
{
|
||||
$subtract: ['$vu', '$vd'],
|
||||
},
|
||||
{
|
||||
$add: ['$vu', '$vd'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
{
|
||||
allowDiskUse: true,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$group: {
|
||||
_id: {
|
||||
$arrayElemAt: [{
|
||||
$split: ['$_id', ':']
|
||||
}, 1]
|
||||
},
|
||||
vu: {
|
||||
$sum: {
|
||||
$cond: [{
|
||||
$gt: ['$v', 0]
|
||||
}, '$v', 0]
|
||||
)
|
||||
.forEach(r => {
|
||||
db.puzzle2_puzzle.update(
|
||||
{ _id: r._id },
|
||||
{
|
||||
$set: {
|
||||
vote: r.v,
|
||||
vd: NumberInt(r.vd),
|
||||
vu: NumberInt(r.vu),
|
||||
},
|
||||
}
|
||||
},
|
||||
vd: {
|
||||
$sum: {
|
||||
$cond: [{
|
||||
$lt: ['$v', 0]
|
||||
}, {
|
||||
$subtract: [0, '$v']
|
||||
}, 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$project: {
|
||||
_id: 1,
|
||||
vu: 1,
|
||||
vd: 1,
|
||||
v: {
|
||||
$divide: [{
|
||||
$subtract: ['$vu', '$vd']
|
||||
}, {
|
||||
$add: ['$vu', '$vd']
|
||||
}]
|
||||
}
|
||||
}
|
||||
}], {
|
||||
allowDiskUse: true
|
||||
}).forEach(r => {
|
||||
db.puzzle2_puzzle.update({_id: r._id},{$set:{
|
||||
vote: r.v,
|
||||
vd: NumberInt(r.vd),
|
||||
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,20 +3,29 @@ var ranking = db.ranking;
|
|||
|
||||
var cheats = [];
|
||||
|
||||
ranking.find({}, {
|
||||
user: 1
|
||||
}).forEach(function(r) {
|
||||
if (r.user && users.count({
|
||||
_id: r.user,
|
||||
engine: true
|
||||
}) > 0) cheats.push(r._id);
|
||||
});
|
||||
ranking
|
||||
.find(
|
||||
{},
|
||||
{
|
||||
user: 1,
|
||||
}
|
||||
)
|
||||
.forEach(function (r) {
|
||||
if (
|
||||
r.user &&
|
||||
users.count({
|
||||
_id: r.user,
|
||||
engine: true,
|
||||
}) > 0
|
||||
)
|
||||
cheats.push(r._id);
|
||||
});
|
||||
|
||||
print('Found ' + cheats.length);
|
||||
print(cheats.join(', '));
|
||||
|
||||
cheats.forEach(function(id) {
|
||||
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}
|
||||
'perfs.classical.nb': { $gte: 1 },
|
||||
v: { $exists: false },
|
||||
};
|
||||
|
||||
var done = 0;
|
||||
|
@ -52,13 +52,14 @@ 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 })
|
||||
.sort({ca:-1})
|
||||
db.game5
|
||||
.find(gameQuery, { _id: false, c: true, ca: true })
|
||||
.sort({ ca: -1 })
|
||||
.hint('us_1_ca_-1')
|
||||
.forEach(g => {
|
||||
switch(getPerf(getTc(g))) {
|
||||
switch (getPerf(getTc(g))) {
|
||||
case 'rapid':
|
||||
rapidPerf.nb++;
|
||||
if (!rapidPerf.la) rapidPerf.la = g.ca;
|
||||
|
@ -69,27 +70,27 @@ db.user4.find(query).forEach(u => {
|
|||
break;
|
||||
}
|
||||
});
|
||||
[classicalPerf, rapidPerf].forEach(perf => {
|
||||
if (perf.nb < 10) {
|
||||
if (perf.nb < 5) perf.gl.d = 350;
|
||||
else perf.gl.d = 150;
|
||||
perf.gl.v = 0.06;
|
||||
}
|
||||
if (!perf.la) delete perf.la;
|
||||
perf.nb = NumberInt(perf.nb);
|
||||
});
|
||||
[classicalPerf, rapidPerf].forEach(perf => {
|
||||
if (perf.nb < 10) {
|
||||
if (perf.nb < 5) perf.gl.d = 350;
|
||||
else perf.gl.d = 150;
|
||||
perf.gl.v = 0.06;
|
||||
}
|
||||
if (!perf.la) delete perf.la;
|
||||
perf.nb = NumberInt(perf.nb);
|
||||
});
|
||||
|
||||
var update = {
|
||||
$set: {
|
||||
v: 2 // user version 2
|
||||
}
|
||||
};
|
||||
var update = {
|
||||
$set: {
|
||||
v: 2, // user version 2
|
||||
},
|
||||
};
|
||||
|
||||
if (classicalPerf.nb == 0) update['$unset'] = {'perfs.classical': true};
|
||||
else update['$set']['perfs.classical'] = classicalPerf;
|
||||
if (rapidPerf.nb > 0) update['$set']['perfs.rapid'] = rapidPerf;
|
||||
if (classicalPerf.nb == 0) update['$unset'] = { 'perfs.classical': true };
|
||||
else update['$set']['perfs.classical'] = classicalPerf;
|
||||
if (rapidPerf.nb > 0) update['$set']['perfs.rapid'] = rapidPerf;
|
||||
|
||||
db.user4.update({_id:u._id}, update);
|
||||
db.perf_stat.remove({_id:u._id + '/3'});
|
||||
done++;
|
||||
db.user4.update({ _id: u._id }, update);
|
||||
db.perf_stat.remove({ _id: u._id + '/3' });
|
||||
done++;
|
||||
});
|
||||
|
|
|
@ -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},
|
||||
'perfs.classical.nb': { $gte: 1 },
|
||||
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,13 +54,14 @@ 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 })
|
||||
.sort({ca:-1})
|
||||
db.game5
|
||||
.find(gameQuery, { _id: false, c: true, ca: true })
|
||||
.sort({ ca: -1 })
|
||||
.hint('us_1_ca_-1')
|
||||
.forEach(g => {
|
||||
switch(getPerf(getTc(g))) {
|
||||
switch (getPerf(getTc(g))) {
|
||||
case 'rapid':
|
||||
rapidPerf.nb++;
|
||||
if (!rapidPerf.la) rapidPerf.la = g.ca;
|
||||
|
@ -71,27 +72,27 @@ db.user4.find(query).forEach(u => {
|
|||
break;
|
||||
}
|
||||
});
|
||||
[classicalPerf, rapidPerf].forEach(perf => {
|
||||
if (perf.nb < 10) {
|
||||
if (perf.nb < 5) perf.gl.d = 350;
|
||||
else perf.gl.d = 150;
|
||||
perf.gl.v = 0.06;
|
||||
}
|
||||
if (!perf.la) delete perf.la;
|
||||
perf.nb = NumberInt(perf.nb);
|
||||
});
|
||||
[classicalPerf, rapidPerf].forEach(perf => {
|
||||
if (perf.nb < 10) {
|
||||
if (perf.nb < 5) perf.gl.d = 350;
|
||||
else perf.gl.d = 150;
|
||||
perf.gl.v = 0.06;
|
||||
}
|
||||
if (!perf.la) delete perf.la;
|
||||
perf.nb = NumberInt(perf.nb);
|
||||
});
|
||||
|
||||
var update = {
|
||||
$set: {
|
||||
v: 2 // user version 2
|
||||
}
|
||||
};
|
||||
var update = {
|
||||
$set: {
|
||||
v: 2, // user version 2
|
||||
},
|
||||
};
|
||||
|
||||
if (classicalPerf.nb == 0) update['$unset'] = {'perfs.classical': true};
|
||||
else update['$set']['perfs.classical'] = classicalPerf;
|
||||
if (rapidPerf.nb > 0) update['$set']['perfs.rapid'] = rapidPerf;
|
||||
if (classicalPerf.nb == 0) update['$unset'] = { 'perfs.classical': true };
|
||||
else update['$set']['perfs.classical'] = classicalPerf;
|
||||
if (rapidPerf.nb > 0) update['$set']['perfs.rapid'] = rapidPerf;
|
||||
|
||||
db.user4.update({_id:u._id, v:{$exists:false}}, update);
|
||||
db.perf_stat.remove({_id:u._id + '/3'});
|
||||
done++;
|
||||
db.user4.update({ _id: u._id, v: { $exists: false } }, update);
|
||||
db.perf_stat.remove({ _id: u._id + '/3' });
|
||||
done++;
|
||||
});
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
var id = 'RWtJ4aKC';
|
||||
|
||||
var relay = db.relay.findOne({_id:id});
|
||||
var relay = db.relay.findOne({ _id: id });
|
||||
if (relay) {
|
||||
print('Removing ' + relay.games.length + ' games');
|
||||
relay.games.forEach(function(g) {
|
||||
db.game5.remove({_id:g.id});
|
||||
relay.games.forEach(function (g) {
|
||||
db.game5.remove({ _id: g.id });
|
||||
});
|
||||
print('Removing relay');
|
||||
db.relay.remove({_id:id});
|
||||
db.relay.remove({ _id: id });
|
||||
}
|
||||
|
|
|
@ -1,50 +1,54 @@
|
|||
db.report2.drop();
|
||||
|
||||
db.report.aggregate(
|
||||
[
|
||||
{$group:{
|
||||
_id: {
|
||||
user: '$user',
|
||||
reason: '$reason',
|
||||
processedBy: '$processedBy'
|
||||
db.report
|
||||
.aggregate(
|
||||
[
|
||||
{
|
||||
$group: {
|
||||
_id: {
|
||||
user: '$user',
|
||||
reason: '$reason',
|
||||
processedBy: '$processedBy',
|
||||
},
|
||||
reports: { $push: '$$ROOT' },
|
||||
},
|
||||
},
|
||||
reports:{$push:'$$ROOT'}
|
||||
}}
|
||||
],
|
||||
{allowDiskUse:true}
|
||||
).toArray().forEach(group => {
|
||||
],
|
||||
{ allowDiskUse: true }
|
||||
)
|
||||
.toArray()
|
||||
.forEach(group => {
|
||||
var reports = group.reports;
|
||||
var first = reports[0];
|
||||
|
||||
var reports = group.reports;
|
||||
var first = reports[0];
|
||||
|
||||
var atoms = [];
|
||||
reports.forEach(r => {
|
||||
var same = atoms.find(a => a.by === r.createdBy);
|
||||
if (same) same.text += '\n\n' + r.text;
|
||||
else atoms.push({
|
||||
by: r.createdBy,
|
||||
at: r.createdAt,
|
||||
text: r.text,
|
||||
score: 30
|
||||
var atoms = [];
|
||||
reports.forEach(r => {
|
||||
var same = atoms.find(a => a.by === r.createdBy);
|
||||
if (same) same.text += '\n\n' + r.text;
|
||||
else
|
||||
atoms.push({
|
||||
by: r.createdBy,
|
||||
at: r.createdAt,
|
||||
text: r.text,
|
||||
score: 30,
|
||||
});
|
||||
});
|
||||
|
||||
var report = {
|
||||
_id: first._id,
|
||||
user: first.user,
|
||||
reason: first.reason,
|
||||
room: first.room,
|
||||
atoms: atoms,
|
||||
score: atoms.reduce((acc, atom) => acc + atom.score, 0),
|
||||
open: !first.processedBy,
|
||||
};
|
||||
if (first.processedBy) report.processedBy = first.processedBy;
|
||||
|
||||
db.report2.insert(report);
|
||||
});
|
||||
|
||||
var report = {
|
||||
_id: first._id,
|
||||
user: first.user,
|
||||
reason: first.reason,
|
||||
room: first.room,
|
||||
atoms: atoms,
|
||||
score: atoms.reduce((acc, atom) => acc + atom.score, 0),
|
||||
open: !first.processedBy
|
||||
};
|
||||
if (first.processedBy)
|
||||
report.processedBy = first.processedBy;
|
||||
|
||||
db.report2.insert(report);
|
||||
});
|
||||
|
||||
db.report2.createIndex({room:1,score:-1},{partialFilterExpression:{open:true},name:'best_open'});
|
||||
db.report2.createIndex({'inquiry.mod':1},{partialFilterExpression:{'inquiry.mod':{$exists:true}}});
|
||||
db.report2.createIndex({user:1});
|
||||
db.report2.createIndex({'atoms.by':1});
|
||||
db.report2.createIndex({ room: 1, score: -1 }, { partialFilterExpression: { open: true }, name: 'best_open' });
|
||||
db.report2.createIndex({ 'inquiry.mod': 1 }, { partialFilterExpression: { 'inquiry.mod': { $exists: true } } });
|
||||
db.report2.createIndex({ user: 1 });
|
||||
db.report2.createIndex({ 'atoms.by': 1 });
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
db.report2.update({room:'coms'},{$set:{room:'comm'}},{multi:1});
|
||||
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();
|
||||
db.report2.distinct('user', { room: 'comm' }).forEach(user => {
|
||||
const reports = db.report2.find({ user: user, room: 'comm' }).toArray();
|
||||
|
||||
const report = reports[0];
|
||||
const others = reports.slice(1);
|
||||
|
@ -18,7 +17,7 @@ db.report2.distinct('user',{room:'comm'}).forEach(user => {
|
|||
if (!report.processedBy || report.open) delete report.processedBy;
|
||||
report.atoms.sort((a, b) => a.at > b.at);
|
||||
|
||||
db.report2.update({_id:report._id},{$set:report});
|
||||
db.report2.update({ _id: report._id }, { $set: report });
|
||||
|
||||
if (others.length) db.report2.remove({_id:{$in:others.map(r => r._id)}});
|
||||
if (others.length) db.report2.remove({ _id: { $in: others.map(r => r._id) } });
|
||||
});
|
||||
|
|
|
@ -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';
|
||||
|
@ -9,5 +8,5 @@ db.report.find().forEach(r => {
|
|||
else if (r.reason === 'troll') room = 'coms';
|
||||
else if (r.reason === 'insult') room = 'coms';
|
||||
|
||||
db.report.update({_id: r._id},{$set:{room: room}});
|
||||
db.report.update({ _id: r._id }, { $set: { room: room } });
|
||||
});
|
||||
|
|
|
@ -1,22 +1,32 @@
|
|||
db.report.find({
|
||||
processedBy: {
|
||||
$exists: false
|
||||
}
|
||||
}).sort({
|
||||
createdAt: -1
|
||||
}).skip(150).limit(1).toArray().forEach(function(report) {
|
||||
db.report.update({
|
||||
db.report
|
||||
.find({
|
||||
processedBy: {
|
||||
$exists: false
|
||||
$exists: false,
|
||||
},
|
||||
createdAt: {
|
||||
$gt: report.createdAt
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
processedBy: 'lichess-sweep'
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
})
|
||||
.sort({
|
||||
createdAt: -1,
|
||||
})
|
||||
.skip(150)
|
||||
.limit(1)
|
||||
.toArray()
|
||||
.forEach(function (report) {
|
||||
db.report.update(
|
||||
{
|
||||
processedBy: {
|
||||
$exists: false,
|
||||
},
|
||||
createdAt: {
|
||||
$gt: report.createdAt,
|
||||
},
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
processedBy: 'lichess-sweep',
|
||||
},
|
||||
},
|
||||
{
|
||||
multi: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,41 +1,45 @@
|
|||
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)) {
|
||||
const rating = ratings[k];
|
||||
const id = k.toLowerCase();
|
||||
const user = db.user4.findOne({_id:id});
|
||||
const user = db.user4.findOne({ _id: id });
|
||||
if (user.perfs[perf] && user.perfs[perf].nb) {
|
||||
const set = { [`perfs.${perf}.gl.r`]: rating };
|
||||
const push = {
|
||||
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:{
|
||||
[`perfs.${perf}`]: {
|
||||
"gl": {
|
||||
"r": rating,
|
||||
"d": 150,
|
||||
"v": 0.06
|
||||
db.user4.update({ _id: id }, { $set: set, $push: push });
|
||||
} else {
|
||||
db.user4.update(
|
||||
{ _id: id },
|
||||
{
|
||||
$set: {
|
||||
[`perfs.${perf}`]: {
|
||||
gl: {
|
||||
r: rating,
|
||||
d: 150,
|
||||
v: 0.06,
|
||||
},
|
||||
nb: NumberInt(0),
|
||||
re: [],
|
||||
},
|
||||
},
|
||||
"nb": NumberInt(0),
|
||||
"re": [ ]
|
||||
}
|
||||
}});
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,32 @@
|
|||
var ids = [];
|
||||
|
||||
db.simul.find({
|
||||
status: 20
|
||||
}).forEach(function(s) {
|
||||
var finished = true;
|
||||
printjson(s);
|
||||
s.pairings.forEach(function(p) {
|
||||
if (p.status < 25 && p.status !== 10) finished = false;
|
||||
db.simul
|
||||
.find({
|
||||
status: 20,
|
||||
})
|
||||
.forEach(function (s) {
|
||||
var finished = true;
|
||||
printjson(s);
|
||||
s.pairings.forEach(function (p) {
|
||||
if (p.status < 25 && p.status !== 10) finished = false;
|
||||
});
|
||||
if (finished) ids.push(s._id);
|
||||
});
|
||||
if (finished) ids.push(s._id);
|
||||
});
|
||||
|
||||
db.simul.update({
|
||||
_id: {
|
||||
$in: ids
|
||||
db.simul.update(
|
||||
{
|
||||
_id: {
|
||||
$in: ids,
|
||||
},
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
status: NumberInt(30),
|
||||
finishedAt: new Date(),
|
||||
hostGameId: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
multi: 1,
|
||||
}
|
||||
}, {
|
||||
$set: {
|
||||
status: NumberInt(30),
|
||||
finishedAt: new Date(),
|
||||
hostGameId: null
|
||||
}
|
||||
}, {
|
||||
multi: 1
|
||||
});
|
||||
);
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
db.streamer.update({
|
||||
liveAt:{$exists:0},
|
||||
createdAt:{$lt:new Date(Date.now() - 1000 * 3600 * 24 * 7)}
|
||||
},{
|
||||
$set:{
|
||||
'approval.granted':false,
|
||||
demoted:true
|
||||
db.streamer.update(
|
||||
{
|
||||
liveAt: { $exists: 0 },
|
||||
createdAt: { $lt: new Date(Date.now() - 1000 * 3600 * 24 * 7) },
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
'approval.granted': false,
|
||||
demoted: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
multi: 1,
|
||||
}
|
||||
},{
|
||||
multi:1
|
||||
})
|
||||
);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
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});
|
||||
var study = db.study.findOne({ _id: chap.studyId });
|
||||
return `https://lichess.org/study/${study._id}/${chap._id} by ${study.ownerId}`;
|
||||
}
|
||||
|
||||
|
@ -12,7 +15,7 @@ db.study_chapter.find().forEach(chap => {
|
|||
try {
|
||||
depth = depthOf(chap.root);
|
||||
if (depth > maxDepth) print(`${urlOf(chap)} ${depth}`);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
print(`${urlOf(chap)} ${e}`);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
db.study_chapter.find({
|
||||
// _id: 'MiRw4nlk',
|
||||
tags: {
|
||||
$exists: false
|
||||
}
|
||||
}).forEach(function(c) {
|
||||
var tags = c.setup.fromPgn ? c.setup.fromPgn.tags : [];
|
||||
db.study_chapter.update({
|
||||
_id: c._id
|
||||
}, {
|
||||
$set: {
|
||||
tags: tags
|
||||
db.study_chapter
|
||||
.find({
|
||||
// _id: 'MiRw4nlk',
|
||||
tags: {
|
||||
$exists: false,
|
||||
},
|
||||
$unset: {
|
||||
'setup.fromPgn': !!c.setup.fromPgn
|
||||
}
|
||||
})
|
||||
.forEach(function (c) {
|
||||
var tags = c.setup.fromPgn ? c.setup.fromPgn.tags : [];
|
||||
db.study_chapter.update(
|
||||
{
|
||||
_id: c._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
tags: tags,
|
||||
},
|
||||
$unset: {
|
||||
'setup.fromPgn': !!c.setup.fromPgn,
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ print(`parallelism: ${parallelism}, instance: ${instance}`);
|
|||
|
||||
const idChars = 'abcdefghyjklmnopqrstuvwxyzABCDEFGHYJKLMNOPQRSTUVWXYZ0123456789'.split('');
|
||||
const sliceSize = idChars.length / parallelism;
|
||||
const charSlice = idChars.slice(sliceSize * (instance -1), sliceSize * instance);
|
||||
const charSlice = idChars.slice(sliceSize * (instance - 1), sliceSize * instance);
|
||||
const firstCharRegex = new RegExp('^[' + charSlice.join('') + ']');
|
||||
print(firstCharRegex);
|
||||
|
||||
|
@ -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,54 +38,64 @@ let batch = [];
|
|||
const batchSize = 1000;
|
||||
const totalNb = (db.study_chapter_backup.count() - db.study_chapter_flat.count()) / parallelism;
|
||||
|
||||
db.study_chapter_backup.aggregate([
|
||||
{$lookup:{
|
||||
from:'study_chapter_flat',
|
||||
as:'flat',
|
||||
let:{id:'$_id'},
|
||||
pipeline:[{$match:{$expr:{$eq:['$_id', '$$id']}}},{$project:{_id:1}}]
|
||||
}},
|
||||
{ $match:{flat:[]} },
|
||||
{ $project:{flat:false} }
|
||||
]).forEach(c => {
|
||||
try {
|
||||
sumSizeFrom += Object.bsonsize(c);
|
||||
} catch (e) {
|
||||
tooDeepNb++;
|
||||
}
|
||||
const tree = {};
|
||||
try {
|
||||
flattenEach('', c.root, tree);
|
||||
} catch (e) {
|
||||
print(`ERROR ${c._id} ${e}`);
|
||||
return;
|
||||
}
|
||||
c.root = tree;
|
||||
sumSizeTo += Object.bsonsize(c);
|
||||
const nbMoves = Object.keys(c.root).length;
|
||||
if (nbMoves > 3000) tooBigNb++;
|
||||
else batch.push(c);
|
||||
i++;
|
||||
sumMoves += nbMoves;
|
||||
if (i % batchSize == 0) {
|
||||
coll.insertMany(batch, {
|
||||
ordered: 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 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}`);
|
||||
lastAt = at;
|
||||
sumSizeFrom = 0;
|
||||
sumSizeTo = 0;
|
||||
sumMoves = 0;
|
||||
tooBigNb = 0;
|
||||
tooDeepNb = 0;
|
||||
}
|
||||
});
|
||||
db.study_chapter_backup
|
||||
.aggregate([
|
||||
{
|
||||
$lookup: {
|
||||
from: 'study_chapter_flat',
|
||||
as: 'flat',
|
||||
let: { id: '$_id' },
|
||||
pipeline: [{ $match: { $expr: { $eq: ['$_id', '$$id'] } } }, { $project: { _id: 1 } }],
|
||||
},
|
||||
},
|
||||
{ $match: { flat: [] } },
|
||||
{ $project: { flat: false } },
|
||||
])
|
||||
.forEach(c => {
|
||||
try {
|
||||
sumSizeFrom += Object.bsonsize(c);
|
||||
} catch (e) {
|
||||
tooDeepNb++;
|
||||
}
|
||||
const tree = {};
|
||||
try {
|
||||
flattenEach('', c.root, tree);
|
||||
} catch (e) {
|
||||
print(`ERROR ${c._id} ${e}`);
|
||||
return;
|
||||
}
|
||||
c.root = tree;
|
||||
sumSizeTo += Object.bsonsize(c);
|
||||
const nbMoves = Object.keys(c.root).length;
|
||||
if (nbMoves > 3000) tooBigNb++;
|
||||
else batch.push(c);
|
||||
i++;
|
||||
sumMoves += nbMoves;
|
||||
if (i % batchSize == 0) {
|
||||
coll.insertMany(batch, {
|
||||
ordered: 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 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}`
|
||||
);
|
||||
lastAt = at;
|
||||
sumSizeFrom = 0;
|
||||
sumSizeTo = 0;
|
||||
sumMoves = 0;
|
||||
tooBigNb = 0;
|
||||
tooDeepNb = 0;
|
||||
}
|
||||
});
|
||||
coll.insertMany(batch, {
|
||||
ordered: false,
|
||||
// writeConcern: { w: 0, j: false }
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
db.study.find({},{members:1}).forEach(s => {
|
||||
|
||||
for(let i in s.members) {
|
||||
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}});
|
||||
|
||||
db.study.update({ _id: s._id }, { $set: { members: s.members } });
|
||||
});
|
||||
|
|
|
@ -8,9 +8,8 @@ function dig(chapId, node, path) {
|
|||
var set = {};
|
||||
set[`${path}.n`] = [];
|
||||
printjson(set);
|
||||
db.study_chapter.update({_id:chapId},{$set:set});
|
||||
}
|
||||
else {
|
||||
db.study_chapter.update({ _id: chapId }, { $set: set });
|
||||
} 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 });
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
*
|
||||
* only visible with mongoexport, but cause bugs when used with reactivemongo
|
||||
*/
|
||||
db.study.find({updatedAt:{$gt:new Date(Date.now() - 1000 * 3600 * 12)}}).forEach(s1 => {
|
||||
db.study.find({ updatedAt: { $gt: new Date(Date.now() - 1000 * 3600 * 12) } }).forEach(s1 => {
|
||||
let id = s1._id;
|
||||
let u1 = s1.updatedAt;
|
||||
db.study.update({_id: id},{$unset:{updatedAt:1}});
|
||||
let s2 = db.study.findOne({_id: id});
|
||||
db.study.update({ _id: id }, { $unset: { updatedAt: 1 } });
|
||||
let s2 = db.study.findOne({ _id: id });
|
||||
let u2 = s2.updatedAt;
|
||||
let u3;
|
||||
if (u2) {
|
||||
let newer = u1 > u2 ? 'first' : 'second';
|
||||
print(`Found duplicated updatedAt for ${id}, ${newer} one is newer`);
|
||||
db.study.update({_id: id},{$unset:{updatedAt:1}});
|
||||
db.study.update({ _id: id }, { $unset: { updatedAt: 1 } });
|
||||
u3 = u1 > u2 ? u1 : u2;
|
||||
} else {
|
||||
u3 = u1;
|
||||
}
|
||||
db.study.update({_id: id},{$set:{updatedAt: u3}});
|
||||
db.study.update({ _id: id }, { $set: { updatedAt: u3 } });
|
||||
});
|
||||
|
|
|
@ -1,34 +1,43 @@
|
|||
db.tournament.aggregate({
|
||||
$match: {
|
||||
_id: "eY3dydc7"
|
||||
}
|
||||
}, {
|
||||
$project: {
|
||||
'pairings.u': true,
|
||||
_id: false
|
||||
}
|
||||
}, {
|
||||
$unwind: '$pairings'
|
||||
}, {
|
||||
$unwind: '$pairings.u'
|
||||
}, {
|
||||
$group: {
|
||||
_id: '$pairings.u',
|
||||
nb: {
|
||||
$sum: 1
|
||||
db.tournament
|
||||
.aggregate(
|
||||
{
|
||||
$match: {
|
||||
_id: 'eY3dydc7',
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
'pairings.u': true,
|
||||
_id: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: '$pairings',
|
||||
},
|
||||
{
|
||||
$unwind: '$pairings.u',
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: '$pairings.u',
|
||||
nb: {
|
||||
$sum: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
nb: {
|
||||
$gte: 5,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$match: {
|
||||
nb: {
|
||||
$gte: 5
|
||||
}
|
||||
}
|
||||
}).result.forEach(function(r) {
|
||||
db.trophy.insert({
|
||||
_id: 'survivor/' + r._id,
|
||||
kind: 'marathonSurvivor',
|
||||
user: r._id,
|
||||
date: new Date()
|
||||
)
|
||||
.result.forEach(function (r) {
|
||||
db.trophy.insert({
|
||||
_id: 'survivor/' + r._id,
|
||||
kind: 'marathonSurvivor',
|
||||
user: r._id,
|
||||
date: new Date(),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,26 +1,35 @@
|
|||
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},{
|
||||
$set:{
|
||||
finishedAt: new Date(),
|
||||
'settings.n': s.round,
|
||||
canceled: new Date()
|
||||
},
|
||||
$unset:{
|
||||
nextRoundAt: 1,
|
||||
featurable: 1
|
||||
}
|
||||
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 },
|
||||
{
|
||||
$set: {
|
||||
finishedAt: new Date(),
|
||||
'settings.n': s.round,
|
||||
canceled: new Date(),
|
||||
},
|
||||
$unset: {
|
||||
nextRoundAt: 1,
|
||||
featurable: 1,
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
db.swiss.find({nbOngoing:{$ne:0}}).forEach(s => {
|
||||
const count = db.swiss_pairing.count({s:s._id,t:true});
|
||||
db.swiss.find({ nbOngoing: { $ne: 0 } }).forEach(s => {
|
||||
const count = db.swiss_pairing.count({ s: s._id, t: true });
|
||||
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});
|
||||
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 => {
|
||||
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:{
|
||||
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)
|
||||
}});
|
||||
db.swiss_pairing.find({ s: swiss._id }).forEach(p => {
|
||||
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,
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
db.swiss_player.update({s:swiss._id},{$unset:{n:1}},{multi:1});
|
||||
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,9 +1,9 @@
|
|||
db.team.find().forEach(t => {
|
||||
if (t.leaders.length == 1 && t.leaders[0] == t.createdBy) return;
|
||||
const leaders = db.team_member.distinct('user',{team:t._id,user:{$in:t.leaders}});
|
||||
const leaders = db.team_member.distinct('user', { team: t._id, user: { $in: t.leaders } });
|
||||
if (leaders.length != t.leaders.length) {
|
||||
if (!leaders.length) leaders.push(t.createdBy);
|
||||
print(`${t._id} ${t.name} ${t.leaders.join(',')} -> ${leaders.join(',')}`);
|
||||
db.team.update({_id:t._id},{$set:{leaders:leaders}});
|
||||
db.team.update({ _id: t._id }, { $set: { leaders: leaders } });
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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});
|
||||
db.team_member.find().forEach(function (member) {
|
||||
var user = db.user2.findOne({ _id: member.user });
|
||||
if (!user || !user.enabled) {
|
||||
print("Removing " + member._id);
|
||||
db.team_member.remove({_id: 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({
|
||||
notifies: userId,
|
||||
'content.type': 'titledTourney',
|
||||
'content.id': tournamentId
|
||||
})) return;
|
||||
if (
|
||||
db.notify.count({
|
||||
notifies: userId,
|
||||
'content.type': 'titledTourney',
|
||||
'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++;
|
||||
});
|
||||
|
|
1544
bin/mongodb/tor.js
1544
bin/mongodb/tor.js
File diff suppressed because one or more lines are too long
|
@ -1,20 +1,26 @@
|
|||
function toInt(obj) {
|
||||
return function(prop) {
|
||||
return function (prop) {
|
||||
if (typeof obj[prop] != 'undefined') obj[prop] = NumberInt(obj[prop]);
|
||||
};
|
||||
}
|
||||
// db.tournament.find({_id:'fefNHKaL'}).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) {
|
||||
['s', 't'].forEach(toInt(pairing));
|
||||
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) {
|
||||
['s', 't'].forEach(toInt(pairing));
|
||||
});
|
||||
if (tour.players)
|
||||
tour.players.forEach(function (player) {
|
||||
['rating', 'score'].forEach(toInt(player));
|
||||
});
|
||||
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);
|
||||
});
|
||||
if (tour.players) tour.players.forEach(function(player) {
|
||||
['rating', 'score'].forEach(toInt(player));
|
||||
});
|
||||
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);
|
||||
});
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
db.tournament2.find({
|
||||
startsAt: {"$gt": new Date()}
|
||||
}, {
|
||||
id: 1,
|
||||
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}, {
|
||||
$set: {
|
||||
startsAt: d.startsAt
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
db.tournament2
|
||||
.find(
|
||||
{
|
||||
startsAt: { $gt: new Date() },
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
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 },
|
||||
{
|
||||
$set: {
|
||||
startsAt: d.startsAt,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
db.tournament.find({}, {players:1}).forEach(function(tour) {
|
||||
db.tournament.find({}, { players: 1 }).forEach(function (tour) {
|
||||
for (var i in tour.players) {
|
||||
var p = tour.players[i];
|
||||
p.rating = p.elo;
|
||||
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,37 +10,39 @@ 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
|
||||
}); //.limit(max);
|
||||
var cursor = orig
|
||||
.find({
|
||||
status: 30,
|
||||
})
|
||||
.sort({
|
||||
createdAt: -1,
|
||||
}); //.limit(max);
|
||||
|
||||
function int(i) {
|
||||
return NumberInt(i);
|
||||
|
@ -49,14 +51,14 @@ function int(i) {
|
|||
var uidIt = 0;
|
||||
|
||||
function uid() {
|
||||
return "i" + uidIt++;
|
||||
return 'i' + uidIt++;
|
||||
}
|
||||
|
||||
var it = 0;
|
||||
var max = cursor.count();
|
||||
var dat = new Date().getTime() / 1000;
|
||||
|
||||
cursor.forEach(function(o) {
|
||||
cursor.forEach(function (o) {
|
||||
dest.insert(mkTour(o));
|
||||
insertPlayers(o);
|
||||
insertPairings(o);
|
||||
|
@ -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,10 +130,11 @@ 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 = {
|
||||
freq: o.schedule.freq,
|
||||
speed: o.schedule.speed
|
||||
};
|
||||
if (o.schedule)
|
||||
n.schedule = {
|
||||
freq: o.schedule.freq,
|
||||
speed: o.schedule.speed,
|
||||
};
|
||||
if (nbPlayers) n.winner = o.players[0].id;
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -1,31 +1,34 @@
|
|||
print("move user nb* to user.count.*");
|
||||
db.user2.find().forEach(function(user) {
|
||||
db.user2.update({
|
||||
'_id': user['_id']
|
||||
}, {
|
||||
'$unset': {
|
||||
nbAi: true,
|
||||
nbDraws: true,
|
||||
nbDrawsH: true,
|
||||
nbGames: true,
|
||||
nbLosses: true,
|
||||
nbLossesH: true,
|
||||
nbRatedGames: true,
|
||||
nbWins: true,
|
||||
nbWinsH: true
|
||||
print('move user nb* to user.count.*');
|
||||
db.user2.find().forEach(function (user) {
|
||||
db.user2.update(
|
||||
{
|
||||
_id: user['_id'],
|
||||
},
|
||||
'$set': {
|
||||
count: {
|
||||
ai: user.nbAi || 0,
|
||||
draw: user.nbDraws || 0,
|
||||
drawH: user.nbDrawsH || 0,
|
||||
game: user.nbGames || 0,
|
||||
loss: user.nbLosses || 0,
|
||||
lossH: user.nbLossesH || 0,
|
||||
rated: user.nbRatedGames || 0,
|
||||
win: user.nbWins || 0,
|
||||
winH: user.nbWinsH || 0
|
||||
}
|
||||
{
|
||||
$unset: {
|
||||
nbAi: true,
|
||||
nbDraws: true,
|
||||
nbDrawsH: true,
|
||||
nbGames: true,
|
||||
nbLosses: true,
|
||||
nbLossesH: true,
|
||||
nbRatedGames: true,
|
||||
nbWins: true,
|
||||
nbWinsH: true,
|
||||
},
|
||||
$set: {
|
||||
count: {
|
||||
ai: user.nbAi || 0,
|
||||
draw: user.nbDraws || 0,
|
||||
drawH: user.nbDrawsH || 0,
|
||||
game: user.nbGames || 0,
|
||||
loss: user.nbLosses || 0,
|
||||
lossH: user.nbLossesH || 0,
|
||||
rated: user.nbRatedGames || 0,
|
||||
win: user.nbWins || 0,
|
||||
winH: user.nbWinsH || 0,
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
var user = db.user4.findOne({_id: 'thibault'});
|
||||
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,33 +1,40 @@
|
|||
var it = 0;
|
||||
var batchSize = 100;
|
||||
|
||||
db.user4.find({
|
||||
createdAt: {
|
||||
$gt: ISODate("2015-02-03T20:00:09.148Z")
|
||||
}
|
||||
}).forEach(function(u) {
|
||||
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
|
||||
}, {
|
||||
$unset: {
|
||||
createdAt: true
|
||||
db.user4.update(
|
||||
{
|
||||
_id: u._id,
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
createdAt: u.createdAt,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
++it;
|
||||
if (it % batchSize == 0) {
|
||||
print(it);
|
||||
sleep(100);
|
||||
}
|
||||
});
|
||||
|
||||
db.user4.update({
|
||||
_id: u._id
|
||||
}, {
|
||||
$set: {
|
||||
createdAt: u.createdAt
|
||||
}
|
||||
})
|
||||
|
||||
++it;
|
||||
if (it % batchSize == 0) {
|
||||
print(it);
|
||||
sleep(100);
|
||||
}
|
||||
});
|
||||
|
||||
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({
|
||||
us: userId,
|
||||
'us.1': userId
|
||||
}, {
|
||||
$pull: {
|
||||
us: userId
|
||||
},
|
||||
$unset: { p1: true }
|
||||
}, multi).nModified + ' done');
|
||||
print(
|
||||
db.game5.update(
|
||||
{
|
||||
us: userId,
|
||||
'us.1': userId,
|
||||
},
|
||||
{
|
||||
$pull: {
|
||||
us: userId,
|
||||
},
|
||||
$unset: { p1: true },
|
||||
},
|
||||
multi
|
||||
).nModified + ' done'
|
||||
);
|
||||
|
||||
print('Set white games as anon');
|
||||
print(db.game5.update({
|
||||
us: userId,
|
||||
'us.0': userId
|
||||
}, {
|
||||
$set: {
|
||||
'us.0': ''
|
||||
},
|
||||
$unset: { p0: true }
|
||||
}, multi).nModified + ' done');
|
||||
print(
|
||||
db.game5.update(
|
||||
{
|
||||
us: userId,
|
||||
'us.0': userId,
|
||||
},
|
||||
{
|
||||
$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();
|
||||
|
||||
|
@ -9,12 +9,11 @@ function nn(x) {
|
|||
return (x | '') !== '';
|
||||
}
|
||||
|
||||
usersToMigrate.forEach(function(u) {
|
||||
|
||||
if ((u.bio | '') !== '') u.profile = {bio: u.bio};
|
||||
usersToMigrate.forEach(function (u) {
|
||||
if ((u.bio | '') !== '') u.profile = { bio: u.bio };
|
||||
delete u.bio;
|
||||
|
||||
collection.insert(u);
|
||||
});
|
||||
|
||||
print("Done!");
|
||||
print('Done!');
|
||||
|
|
|
@ -2,35 +2,39 @@ 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();
|
||||
|
||||
function hintWid(query) {
|
||||
return games.find(query).hint({wid:1}).length();
|
||||
return games.find(query).hint({ wid: 1 }).length();
|
||||
}
|
||||
|
||||
print("Denormalize counts");
|
||||
users.find().forEach(function(user) {
|
||||
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"
|
||||
}
|
||||
});
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue