core: remove ratingHistory

This commit is contained in:
undefined committed 2021-10-10 17:08:09 +08:00
1 parent 5f527658f8
commit fb19c8073f
8 files changed
+11 -77

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.39.11",
"version": "2.39.12",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+1
View File
@@ -62,6 +62,7 @@ class RecordListHandler extends Handler {
if (status) q.status = status;
if (all) {
this.checkPriv(PRIV.PRIV_MANAGE_ALL_DOMAIN);
delete q.contest;
}
let cursor = record.getMulti(all ? '' : domainId, q).sort('_id', -1);
if (!full) cursor = cursor.project(buildProjection(record.PROJECTION_LIST));
-1
View File
@@ -154,7 +154,6 @@ DomainUserSetting(
Setting('setting_storage', 'rpdelta', 0, 'number', 'RP.delta', null, FLAG_HIDDEN | FLAG_DISABLED),
Setting('setting_storage', 'rank', 0, 'number', 'Rank', null, FLAG_DISABLED | FLAG_HIDDEN),
Setting('setting_storage', 'level', 0, 'number', 'level', null, FLAG_HIDDEN | FLAG_DISABLED),
Setting('setting_storage', 'ratingHistory', [], 'text', 'Rating History', null, FLAG_DISABLED | FLAG_HIDDEN),
);
SystemSetting(
+1 -2
View File
@@ -27,7 +27,7 @@ async function runProblem(...arg: any[]) {
pdoc.domainId, { docId: pdoc.docId, rid: { $ne: null } },
).count() + 99) / 100,
);
const p = (pdoc.difficulty || 5) / (Math.sqrt(Math.sqrt(pdoc.nAccept)) + 1);
const p = (pdoc.difficulty || 5) / (Math.sqrt(Math.sqrt(pdoc.nAccept)) + 1) / 10;
for (let page = 1; page <= nPages; page++) {
const psdocs = await problem.getMultiStatus(
pdoc.domainId, { docId: pdoc.docId, rid: { $ne: null } },
@@ -151,7 +151,6 @@ async function runInDomain(id: string, isSub: boolean, report: Function) {
async function update(uid: number, rp: number) {
const udoc = await UserModel.getById(id, +uid);
const $upd: any = { $set: { rp } };
if (isSub) $upd.$push = { ratingHistory: rp };
if (udoc.hasPriv(PRIV.PRIV_USER_PROFILE)) await domain.updateUserInDomain(id, +uid, $upd);
}
for (const uid in udict) tasks.push(update(+uid, udict[uid] + (deltaudict[uid] || 0)));
+6
View File
@@ -551,6 +551,12 @@ const scripts: UpgradeScript[] = [
await RecordModel.coll.updateMany({ input: { $exists: true } }, { $set: { contest: new ObjectID('000000000000000000000000') } });
return true;
},
async function _49_50() {
const _FRESH_INSTALL_IGNORE = 1;
await db.collection('user').updateMany({}, { $unset: { ratingHistory: '' } });
await db.collection('domain').updateMany({}, { $unset: { pidCounter: '' } });
return true;
},
];
export default scripts;
+2 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.23.0",
"version": "4.23.1",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -43,7 +43,6 @@
"fancy-log": "^1.3.3",
"file-loader": "^6.2.0",
"friendly-errors-webpack-plugin": "^1.7.0",
"fs-extra": "^10.0.0",
"graphiql": "^1.4.2",
"gulp": "^4.0.2",
"gulp-cli": "^2.3.0",
@@ -51,7 +50,6 @@
"gulp-if": "^3.0.0",
"gulp-plumber": "^1.2.1",
"gulp-svgmin": "^3.0.0",
"http-proxy": "^1.18.1",
"jquery": "^3.6.0",
"jquery-scroll-lock": "^3.1.3",
"jquery.easing": "^1.4.1",
@@ -101,6 +99,7 @@
},
"dependencies": {
"esbuild": "^0.13.4",
"fs-extra": "^10.0.0",
"js-yaml": "^4.1.0",
"jsesc": "^3.0.2",
"katex": "^0.13.18",
@@ -1,73 +1,10 @@
import Clipboard from 'clipboard';
import * as timeago from 'timeago.js';
import { NamedPage } from 'vj/misc/Page';
import substitute from 'vj/utils/substitute';
import Notification from 'vj/components/notification';
import i18n from 'vj/utils/i18n';
import base64 from 'vj/utils/base64';
async function initChart() {
const history = UiContext.udoc?.ratingHistory || [];
while (history.length > 30) history.shift();
while (history.length < 30) history.unshift(1500);
const echarts = await import('echarts');
const $dom = document.getElementById('rating-placeholder');
const chart = echarts.init($dom, undefined);
chart.setOption({
title: {
text: 'Rating',
left: '1%',
},
tooltip: { trigger: 'axis' },
grid: {
left: '5%',
right: '1%',
bottom: '10%',
},
xAxis: { data: history.map((x, i) => timeago.format(new Date().getTime() + (-30 + i) * 1000 * 3600 * 24, i18n('timeago_locale'))) },
yAxis: { type: 'value', scale: true },
toolbox: {
right: 10,
feature: {
restore: {},
saveAsImage: {},
},
},
visualMap: {
show: false,
pieces: [{
lte: 2000,
color: '#AC3B2A',
}, {
gt: 2000,
lte: 4000,
color: '#AA069F',
}, {
gt: 4000,
lte: 7000,
color: '#FD0100',
}, {
gt: 7000,
lte: 12000,
color: '#FC7D02',
}, {
gt: 12000,
lte: 18000,
color: '#FBDB0F',
}, {
gt: 18000,
color: '#93CE07',
}],
outOfRange: { color: '#999' },
},
series: {
name: 'Rating',
type: 'line',
data: history.map((i) => Math.floor(i)),
},
});
}
const page = new NamedPage('user_detail', () => {
$('[data-copy]').get().forEach((el) => {
const data = $(el).attr('data-copy');
@@ -80,8 +17,6 @@ const page = new NamedPage('user_detail', () => {
Notification.error(substitute(i18n('Copy "{data}" failed :('), { data: decoded }));
});
});
initChart();
window.onresize = initChart;
});
export default page;
@@ -102,11 +102,6 @@
</div>
</div>
</div>
<div class="section">
<div class="section__tab-main">
<div id="rating-placeholder"></div>
</div>
</div>
</div>
<div class="medium-3 columns">
{% if isSelfProfile %}