애플리케이션(PHP, 화면) 개선
This commit is contained in:
1 parent
629c8ff83f
commit
99631c1061
20 files changed
+695
-515
No files matched your search
@@ -73,9 +73,9 @@ class MenuCollection extends DBMethodContainer
|
||||
return $this->getTypingAppList($maestroID, $playerID, $appGroup, $language);
|
||||
|
||||
case 2:
|
||||
if($writingCollection === null)
|
||||
$writingCollection = new WritingCollection($this->mysqli);
|
||||
$systemWritingList = $writingCollection->getSystemList($language);
|
||||
if($this->writingCollection === null)
|
||||
$this->writingCollection = new WritingCollection($this->mysqli);
|
||||
$systemWritingList = $this->writingCollection->getSystemList($language);
|
||||
return $systemWritingList;
|
||||
|
||||
case 4: // mouse play
|
||||
@@ -142,9 +142,9 @@ class MenuCollection extends DBMethodContainer
|
||||
return $this->getTypingActiveAppList($maestroID, $playerID, $appGroup, $language);
|
||||
|
||||
case 2:
|
||||
if($writingCollection === null)
|
||||
$writingCollection = new WritingCollection($this->mysqli);
|
||||
$activeSystemWritingList = $writingCollection->getActiveSystemList($maestroID, $language);
|
||||
if($this->writingCollection === null)
|
||||
$this->writingCollection = new WritingCollection($this->mysqli);
|
||||
$activeSystemWritingList = $this->writingCollection->getActiveSystemList($maestroID, $language);
|
||||
return $activeSystemWritingList;
|
||||
|
||||
case 4: // mouse play
|
||||
@@ -199,7 +199,7 @@ class MenuCollection extends DBMethodContainer
|
||||
|
||||
|
||||
// highest record list
|
||||
public function getHighestRecordList($maestroID, $playerID, $appList)
|
||||
public function getHighestRecordList($maestroID, $playerID, $appGroup, $appList)
|
||||
{
|
||||
switch($appGroup) {
|
||||
case 0: // typing practice
|
||||
@@ -215,15 +215,20 @@ class MenuCollection extends DBMethodContainer
|
||||
|
||||
public function getWritingHighestRecordList($maestroID, $playerID, $appList)
|
||||
{
|
||||
if($writingCollection === null)
|
||||
$writingCollection = new WritingCollection($this->mysqli);
|
||||
if($this->writingCollection === null)
|
||||
$this->writingCollection = new WritingCollection($this->mysqli);
|
||||
|
||||
$writingIDs = array();
|
||||
foreach($appList as $app)
|
||||
$writingIDs[] = $app["writingID"];
|
||||
|
||||
$recordMap = $this->writingCollection->getWritingHighestRecordMap($maestroID, $playerID, $writingIDs);
|
||||
|
||||
$highestRecordArray = array();
|
||||
$count = count($appList);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
$writingID = $appList[$i]["writingID"];
|
||||
foreach($writingIDs as $writingID) {
|
||||
$highestRecord = array();
|
||||
$highestRecord["writingID"] = $writingID;
|
||||
$highestRecord["highestRecord"] = $writingCollection->getWritingHighestRecord($maestroID, $playerID, $writingID);
|
||||
$highestRecord["highestRecord"] = isset($recordMap[$writingID]) ? $recordMap[$writingID] : 0;
|
||||
array_push($highestRecordArray, $highestRecord);
|
||||
}
|
||||
|
||||
@@ -232,35 +237,46 @@ class MenuCollection extends DBMethodContainer
|
||||
|
||||
public function getTypingHighestRecordList($maestroID, $playerID, $appList)
|
||||
{
|
||||
$highestRecordArray = array();
|
||||
$count = count($appList);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
$appID = $appList[$i]["appID"];
|
||||
$highestRecord["appID"] = $appID;
|
||||
$highestRecord["highestRecord"] = $this->getTypingHighestRecord($maestroID, $playerID, $appID);
|
||||
array_push($highestRecordArray, $highestRecord);
|
||||
$appIDs = array();
|
||||
foreach($appList as $app)
|
||||
$appIDs[] = $app["appID"];
|
||||
|
||||
$recordMap = $this->getTypingHighestRecordMap($maestroID, $playerID, $appIDs);
|
||||
|
||||
$highestRecordArray = array();
|
||||
foreach($appIDs as $appID) {
|
||||
$highestRecord = array();
|
||||
$highestRecord["appID"] = $appID;
|
||||
$highestRecord["highestRecord"] = isset($recordMap[$appID]) ? $recordMap[$appID] : 0;
|
||||
array_push($highestRecordArray, $highestRecord);
|
||||
}
|
||||
|
||||
return $highestRecordArray;
|
||||
}
|
||||
|
||||
public function getTypingHighestRecord($maestroID, $playerID, $appID)
|
||||
private function getTypingHighestRecordMap($maestroID, $playerID, $appIDs)
|
||||
{
|
||||
$recordMap = array();
|
||||
if(count($appIDs) === 0)
|
||||
return $recordMap;
|
||||
|
||||
// MAX + GROUP BY: UNIQUE 키가 없는 DB에서도 앱당 1행. COALESCE를 쓰면 FLOAT가 DOUBLE로 바뀌어 소수점이 길어짐
|
||||
$placeholders = implode(",", array_fill(0, count($appIDs), "?"));
|
||||
$query = "
|
||||
SELECT HighestRecord
|
||||
SELECT AppID, MAX(HighestRecord)
|
||||
FROM app_highest_record
|
||||
WHERE MaestroID=? AND PlayerID=? AND AppID=?";
|
||||
WHERE MaestroID=? AND PlayerID=? AND AppID IN (" . $placeholders . ")
|
||||
GROUP BY AppID";
|
||||
$params = array_merge(array($maestroID, $playerID), $appIDs);
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("iii", $maestroID, $playerID, $appID);
|
||||
$stmt->bind_param(str_repeat("i", count($params)), ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($highestRecord);
|
||||
$returnValue = $stmt->fetch();
|
||||
$stmt->bind_result($appID, $highestRecord);
|
||||
while($stmt->fetch())
|
||||
$recordMap[$appID] = $highestRecord;
|
||||
$stmt->close();
|
||||
|
||||
if($returnValue === NULL || $returnValue === FALSE)
|
||||
return 0;
|
||||
|
||||
return $highestRecord;
|
||||
return $recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user