protected function monitor_core($from_secord, $to_secord) { $stepNum = Variables::getStepNum(); $period_secord = $from_secord - $to_secord; $step_secord = (int) ($period_secord / $stepNum); $now = time(); #_tp means time point. $beforebefore_tp = $now - $from_secord; $before_tp = $now - $to_secord; $adjustdt = Adjust::period($beforebefore_tp, $before_tp); $res = Variables::chartjs_line_one_inited_with_time($beforebefore_tp, $step_secord, $stepNum); foreach ($adjustdt as $adj) { $updated = $adj->updated; #$updated = $adj['updated']; $i = (int) (($updated - $beforebefore_tp - 10) / $step_secord); if ($i == $stepNum) { $i -= 1; } $res['datasets'][0]['data'][$i] += 1; } $res = json_encode($res); $url = action('AdjustController@mstep', ['']); return compact('res', 'from_secord', 'to_secord', 'url'); }
public function czh($zid) { $origin = Adjust::one($zid); $A = array(); foreach ($origin as $data) { $A = TaskController::special_merge($A, json_decode($data['data'], true)); } $new = Adjust::cheating($zid); foreach ($new as $data) { $B = json_decode($data->data, true); } $bid = (int) $B[count($B) - 1]['id']; $AA = array(); foreach ($A as $key => $data) { $aid = (int) $A[$key]['id']; if ($aid >= $bid) { $AA[] = $data; } } $A = $AA; if (count($A) < count($B)) { $B = array_slice($B, count($B) - count($A)); } elseif (count($A) > count($B)) { $A = array_slice($A, count($A) - count($B)); } $AA = array(); $BB = array(); foreach ($A as $key => $data) { $AA['[' . $key . ']'] = $data; $BB['[' . $key . ']'] = $B[$key]; } $origin_json = json_encode($AA); $new_json = json_encode($BB); $res = TaskController::check_diff_multi($AA, $BB); $res = json_encode($res); $title = "Cheating detail"; return view('text', compact('res', 'title', 'zid', 'origin_json', 'new_json')); }
protected function one($zid) { $one = Adjust::where('zid', $zid)->orderBy('id', 'desc')->select('data')->get(); return $one; }