作者 王智

统计调试

... ... @@ -64,21 +64,11 @@ class SportA extends Backend
}
$result = array("total" => $list->total(), "rows" => $list->items());
dump($result);
die;
return json($result);
}
return $this->view->fetch();
}
public function sport($person)
{
$newArr = array();
foreach ($person as $key => $v) {
$newArr[$key]['num'] = $v['num'];
}
array_multisort($newArr, SORT_DESC, $person);//SORT_DESC为降序,SORT_ASC为升序
return $person;
}
}
... ...
... ... @@ -338,6 +338,15 @@ class Common extends Api
echo $end_time;
}
public function sport($person)
{
$newArr = array();
foreach ($person as $key => $v) {
$newArr[$key]['num'] = $v['num'];
}
array_multisort($newArr, SORT_DESC, $person);//SORT_DESC为降序,SORT_ASC为升序
return $person;
}
/*排序定时任务A 根据篇数排序*/
public function SportA()
... ... @@ -347,9 +356,14 @@ class Common extends Api
$Array = Db::name('user')->select();
foreach ($Array as $k => $v) {
$DiaryCount = Db::name('diary')->where('user_id', $v['id'])->select();
$List[$k]['user_id'] = $v['id'];
$List[$k]['num'] = count($DiaryCount);
}
$Sport_List = $this->sport($List);
foreach ($Sport_List as $k => $v) {
$data = [
'user_id' => $v['id'],
'num' => count($DiaryCount),
'user_id' => $v['user_id'],
'num' => $v['num'],
'createtime' => time()
];
Db::name('sport_a')->insert($data);
... ... @@ -364,9 +378,14 @@ class Common extends Api
$Array = Db::name('user')->select();
foreach ($Array as $k => $v) {
$DiaryCount = Db::name('diary')->where('user_id', $v['id'])->select();
$List[$k]['user_id'] = $v['id'];
$List[$k]['num'] = count($this->second_array_unique_bykey($DiaryCount, 'createtime'));
}
$Sport_List = $this->sport($List);
foreach ($Sport_List as $k => $v) {
$data = [
'user_id' => $v['id'],
'num' => count($this->second_array_unique_bykey($DiaryCount, 'createtime')),
'user_id' => $v['user_id'],
'num' => $v['num'],
'createtime' => time()
];
Db::name('sport_b')->insert($data);
... ...