更新解决首页其它oj比赛未能按时间排序的问题

This commit is contained in:
Himit_ZH 2021-07-25 14:25:22 +08:00
parent 0cd4301c8e
commit c4c80503f8
7 changed files with 25 additions and 11 deletions

View File

@ -408,7 +408,7 @@ public class FileController {
}
}
private static final ThreadLocal<SimpleDateFormat> threadLocal = new ThreadLocal<SimpleDateFormat>() {
private static final ThreadLocal<SimpleDateFormat> threadLocalTime = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
@ -489,7 +489,7 @@ public class FileController {
for (Judge judge : userSubmissionList) {
String filePath = userDir + File.separator + cpIdMap.getOrDefault(judge.getCpid(), "null")
+ "_(" + threadLocal.get().format(judge.getSubmitTime()) + ")";
+ "_(" + threadLocalTime.get().format(judge.getSubmitTime()) + ")";
// OI模式只取最后一次提交
if (!isACM) {

View File

@ -20,6 +20,7 @@ import top.hcode.hoj.utils.Constants;
import top.hcode.hoj.utils.RedisUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -95,8 +96,6 @@ public class HomeController {
// 从redis获取比赛列表
contestsList = (ArrayList<HashMap<String, Object>>) redisUtils.get(redisKey);
HashMap<String, Object> resp = new HashMap<>();
return CommonResult.successResponse(contestsList,"获取其它OJ最近比赛列表成功");
}

View File

@ -166,7 +166,14 @@ public class ScheduleServiceImpl implements ScheduleService {
}
}
// 把比赛列表按照开始时间排序方便查看
contestsList.sort((o1, o2) -> (int) (((Date) o1.get("beginTime")).getTime() - ((Date) o2.get("beginTime")).getTime()));
contestsList.sort((o1, o2) -> {
long beginTime1 = ((Date) o1.get("beginTime")).getTime();
long beginTime2 = ((Date) o2.get("beginTime")).getTime();
return Long.compare(beginTime1, beginTime2);
});
// 获取对应的redis key
String redisKey = Constants.Schedule.RECENT_OTHER_CONTEST.getCode();
// 缓存时间一天
@ -198,7 +205,7 @@ public class ScheduleServiceImpl implements ScheduleService {
try {
// 防止cf的频率限制
try {
TimeUnit.SECONDS.sleep(5);
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}

View File

@ -12,5 +12,9 @@ ${AnsiColor.BRIGHT_YELLOW}
' : | : ;' ; : .'| \ \ ', / ' : | / ; ' : ;/|
| | ' ,/ ' | '/ : ; : / | | '` ,/ | | \
; : ;--' | : / \ \ .' ; : .' | : .'
| ,/ \ \ .' `---` | ,.' | | ,' @Author Himit_ZH
| ,/ \ \ .' `---` | ,.' | | ,'
'---' `---` '---' `----'
Hcode Online Judge(HOJ) - Backend
@Author Himit_ZH
->Github<- https://www.github.com/HimitZH/HOJ
->Gitee<- https://gitee.com/himitzh0730/hoj

View File

@ -27,8 +27,8 @@ public class HduJudge implements RemoteJudgeStrategy {
public static Map<String, String> headers = MapUtil
.builder(new HashMap<String, String>())
.put("Host", "acm.hdu.edu.cn")
.put("origin", "http://acm.hdu.edu.cn")
.put("referer", "http://acm.hdu.edu.cn")
.put("origin", "https://acm.hdu.edu.cn")
.put("referer", "https://acm.hdu.edu.cn")
.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36")
.map();

View File

@ -12,5 +12,9 @@ ${AnsiColor.BRIGHT_YELLOW}
' : | : ;' ; : .'| \ \ ', / ' : | / ; ' : ;/|
| | ' ,/ ' | '/ : ; : / | | '` ,/ | | \
; : ;--' | : / \ \ .' ; : .' | : .'
| ,/ \ \ .' `---` | ,.' | | ,' @Author Himit_ZH
| ,/ \ \ .' `---` | ,.' | | ,'
'---' `---` '---' `----'
Hcode Online Judge(HOJ) - JudgeServer
@Author Himit_ZH
->Github<- https://www.github.com/HimitZH/HOJ
->Gitee<- https://gitee.com/himitzh0730/hoj

View File

@ -173,7 +173,7 @@
isAdminRole
"
>
<el-col :span="24" style="margin-top: 13px;">
<el-col :span="24" style="margin-top: 13px;" v-if="submission.code">
<Highlight
:code="submission.code"
:language="submission.language"