perf: 优化签到数据

This commit is contained in:
kuaifan
2023-03-04 10:21:48 +08:00
parent 0a84a8718e
commit b5059c13a3
3 changed files with 112 additions and 210 deletions

View File

@@ -1513,6 +1513,7 @@ class UsersController extends AbstractController
* @apiName checkin__list
*
* @apiParam {String} ym 年-月(如:2020-01)
* @apiParam {Number} [before] 取月份之前的数据(单位:月数,最大3)
*
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
* @apiSuccess {String} msg 返回信息(错误描述)
@@ -1526,6 +1527,11 @@ class UsersController extends AbstractController
$start = Carbon::parse(date("Y-m-01 00:00:00", strtotime($ym)));
$end = (clone $start)->addMonth()->subSecond();
//
$before = min(3, intval(Request::input('before')));
if ($before > 0) {
$start = $start->subMonths($before);
}
//
$recordTimes = UserCheckinRecord::getTimes($user->userid, [$start, $end]);
$array = [];
$startT = $start->timestamp;