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

+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 %}