更新解决首页其它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 @Override
protected SimpleDateFormat initialValue() { protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss"); return new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
@ -489,7 +489,7 @@ public class FileController {
for (Judge judge : userSubmissionList) { for (Judge judge : userSubmissionList) {
String filePath = userDir + File.separator + cpIdMap.getOrDefault(judge.getCpid(), "null") String filePath = userDir + File.separator + cpIdMap.getOrDefault(judge.getCpid(), "null")
+ "_(" + threadLocal.get().format(judge.getSubmitTime()) + ")"; + "_(" + threadLocalTime.get().format(judge.getSubmitTime()) + ")";
// OI模式只取最后一次提交 // OI模式只取最后一次提交
if (!isACM) { if (!isACM) {

View File

@ -20,6 +20,7 @@ import top.hcode.hoj.utils.Constants;
import top.hcode.hoj.utils.RedisUtils; import top.hcode.hoj.utils.RedisUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -95,8 +96,6 @@ public class HomeController {
// 从redis获取比赛列表 // 从redis获取比赛列表
contestsList = (ArrayList<HashMap<String, Object>>) redisUtils.get(redisKey); contestsList = (ArrayList<HashMap<String, Object>>) redisUtils.get(redisKey);
HashMap<String, Object> resp = new HashMap<>();
return CommonResult.successResponse(contestsList,"获取其它OJ最近比赛列表成功"); 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 // 获取对应的redis key
String redisKey = Constants.Schedule.RECENT_OTHER_CONTEST.getCode(); String redisKey = Constants.Schedule.RECENT_OTHER_CONTEST.getCode();
// 缓存时间一天 // 缓存时间一天
@ -198,7 +205,7 @@ public class ScheduleServiceImpl implements ScheduleService {
try { try {
// 防止cf的频率限制 // 防止cf的频率限制
try { try {
TimeUnit.SECONDS.sleep(5); TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); 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 public static Map<String, String> headers = MapUtil
.builder(new HashMap<String, String>()) .builder(new HashMap<String, String>())
.put("Host", "acm.hdu.edu.cn") .put("Host", "acm.hdu.edu.cn")
.put("origin", "http://acm.hdu.edu.cn") .put("origin", "https://acm.hdu.edu.cn")
.put("referer", "http://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") .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(); .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 isAdminRole
" "
> >
<el-col :span="24" style="margin-top: 13px;"> <el-col :span="24" style="margin-top: 13px;" v-if="submission.code">
<Highlight <Highlight
:code="submission.code" :code="submission.code"
:language="submission.language" :language="submission.language"