Browse Source

Add reset code length subroutine

master
Pisces000221 7 years ago
parent
commit
52b5fef5b4
  1. 6
      modules/admin.js
  2. 2
      views/admin_other.ejs

6
modules/admin.js

@ -325,6 +325,12 @@ app.post('/admin/other', async (req, res) => {
for (const a of articles) { for (const a of articles) {
await a.resetReplyCountAndTime(); await a.resetReplyCountAndTime();
} }
} else if (req.body.type === 'reset_codelen') {
const submissions = await JudgeState.query();
for (const s of submissions) {
s.code_length = s.code.length;
await s.save();
}
} else { } else {
throw new ErrorMessage("操作类型不正确"); throw new ErrorMessage("操作类型不正确");
} }

2
views/admin_other.ejs

@ -3,6 +3,6 @@
<form method="post" class="ui form"> <form method="post" class="ui form">
<p><button class="ui blue button" name="type" value="reset_count" type="submit">重新计算提交及 AC 数</button></p> <p><button class="ui blue button" name="type" value="reset_count" type="submit">重新计算提交及 AC 数</button></p>
<p><button class="ui blue button" name="type" value="reset_discussion" type="submit">重新计算讨论版回复数和回复时间</button></p> <p><button class="ui blue button" name="type" value="reset_discussion" type="submit">重新计算讨论版回复数和回复时间</button></p>
<!-- <button name="type" value="reset_size" type="submit">重新计算代码大小</button> --> <p><button class="ui blue button" name="type" value="reset_codelen" type="submit">重新计算提交代码长度</button></p>
</form> </form>
<% include admin_footer %> <% include admin_footer %>

Loading…
Cancel
Save