优化查询

master
ELF 5 years ago
parent afbdec3d5d
commit 065245d657

@ -260,10 +260,10 @@ class PromoteRepository {
if (count($ids) == 0) {
return [];
}
$params['time_column'] = 'login_time';
$params['time_column'] = 'create_time';
$map = $this->getPublicAchievementMap($ids, $params);
$promoteIds = $map['promote_id'][1];
$items = M('login_daily_record', 'tab_')->field(['count(DISTINCT user_id) as count', 'promote_id'])->where($map)->group('promote_id')->select();
/* $promoteIds = $map['promote_id'][1];
$tempRows = [];
$tempCount = 0;
$items = [];
@ -272,13 +272,13 @@ class PromoteRepository {
$tempRows[] = $promoteId;
if ($tempCount == 20) {
$map['promote_id'] = ['in', $tempRows];
$rows = M('user_login_record', 'tab_')->field(['count(DISTINCT user_id) as count', 'promote_id'])->where($map)->group('promote_id')->select();
$rows = M('login_daily_record', 'tab_')->field(['count(DISTINCT user_id) as count', 'promote_id'])->where($map)->group('promote_id')->select();
$tempRows = [];
$tempCount = 0;
$items = array_merge($items, $rows);
}
}
*/
$records = [];
foreach ($items as $item) {
$promoteId = $item['promote_id'];

@ -122,9 +122,9 @@ class UserRepository
public function getLoginCountGroupByDay($params)
{
$dayList = $params['dayList'] ?? [];
$params['time_column'] = 'login_time';
$params['time_column'] = 'create_time';
$conditions = $this->getDayGroupConditions($params);
$items = M('user_login_record', 'tab_')->field('FROM_UNIXTIME(login_time, "%Y-%m-%d") as day, count(DISTINCT user_id) as count')
$items = M('login_daily_record', 'tab_')->field('FROM_UNIXTIME(create_time, "%Y-%m-%d") as day, count(DISTINCT user_id) as count')
->where($conditions)
->group('day')
->select();

Loading…
Cancel
Save