@@ -432,7 +432,7 @@ type PlayerScoreRow struct {
432432 PlayerID string `db:"player_id"`
433433 CompetitionID string `db:"competition_id"`
434434 Score int64 `db:"score"`
435- RowNumber int64 `db:"row_number "`
435+ RowNum int64 `db:"row_num "`
436436 CreatedAt int64 `db:"created_at"`
437437 UpdatedAt int64 `db:"updated_at"`
438438}
@@ -1045,10 +1045,10 @@ func competitionResultHandler(c echo.Context) error {
10451045 return fmt .Errorf ("error flockByTenantID: %w" , err )
10461046 }
10471047 defer fl .Close ()
1048- var rowNumber int64
1048+ var rowNum int64
10491049 playerScoreRows := []PlayerScoreRow {}
10501050 for {
1051- rowNumber ++
1051+ rowNum ++
10521052 row , err := r .Read ()
10531053 if err != nil {
10541054 if err == io .EOF {
@@ -1088,7 +1088,7 @@ func competitionResultHandler(c echo.Context) error {
10881088 PlayerID : playerID ,
10891089 CompetitionID : competitionID ,
10901090 Score : score ,
1091- RowNumber : rowNumber ,
1091+ RowNum : rowNum ,
10921092 CreatedAt : now ,
10931093 UpdatedAt : now ,
10941094 })
@@ -1105,12 +1105,12 @@ func competitionResultHandler(c echo.Context) error {
11051105 for _ , ps := range playerScoreRows {
11061106 if _ , err := tenantDB .NamedExecContext (
11071107 ctx ,
1108- "INSERT INTO player_score (id, tenant_id, player_id, competition_id, score, row_number , created_at, updated_at) VALUES (:id, :tenant_id, :player_id, :competition_id, :score, :row_number , :created_at, :updated_at)" ,
1108+ "INSERT INTO player_score (id, tenant_id, player_id, competition_id, score, row_num , created_at, updated_at) VALUES (:id, :tenant_id, :player_id, :competition_id, :score, :row_num , :created_at, :updated_at)" ,
11091109 ps ,
11101110 ); err != nil {
11111111 return fmt .Errorf (
1112- "error Insert player_score: id=%s, tenant_id=%d, playerID=%s, competitionID=%s, score=%d, rowNumber =%d, createdAt=%d, updatedAt=%d, %w" ,
1113- ps .ID , ps .TenantID , ps .PlayerID , ps .CompetitionID , ps .Score , ps .RowNumber , ps .CreatedAt , ps .UpdatedAt , err ,
1112+ "error Insert player_score: id=%s, tenant_id=%d, playerID=%s, competitionID=%s, score=%d, rowNum =%d, createdAt=%d, updatedAt=%d, %w" ,
1113+ ps .ID , ps .TenantID , ps .PlayerID , ps .CompetitionID , ps .Score , ps .RowNum , ps .CreatedAt , ps .UpdatedAt , err ,
11141114 )
11151115
11161116 }
@@ -1231,8 +1231,8 @@ func playerHandler(c echo.Context) error {
12311231 if err := tenantDB .GetContext (
12321232 ctx ,
12331233 & ps ,
1234- // 最後にCSVに登場したスコアを採用する = row_numberが一番行もの
1235- "SELECT * FROM player_score WHERE tenant_id = ? AND competition_id = ? AND player_id = ? ORDER BY row_number DESC LIMIT 1" ,
1234+ // 最後にCSVに登場したスコアを採用する = row_numが一番大きいもの
1235+ "SELECT * FROM player_score WHERE tenant_id = ? AND competition_id = ? AND player_id = ? ORDER BY row_num DESC LIMIT 1" ,
12361236 v .tenantID ,
12371237 c .ID ,
12381238 p .ID ,
@@ -1353,7 +1353,7 @@ func competitionRankingHandler(c echo.Context) error {
13531353 if err := tenantDB .SelectContext (
13541354 ctx ,
13551355 & pss ,
1356- "SELECT * FROM player_score WHERE tenant_id = ? AND competition_id = ? ORDER BY row_number DESC" ,
1356+ "SELECT * FROM player_score WHERE tenant_id = ? AND competition_id = ? ORDER BY row_num DESC" ,
13571357 tenant .ID ,
13581358 competitionID ,
13591359 ); err != nil {
@@ -1362,8 +1362,8 @@ func competitionRankingHandler(c echo.Context) error {
13621362 ranks := make ([]CompetitionRank , 0 , len (pss ))
13631363 scoredPlayerSet := make (map [string ]struct {}, len (pss ))
13641364 for _ , ps := range pss {
1365- // player_scoreが同一player_id内ではrow_numberの降順でソートされているので
1366- // 現れたのが2回目以降のplayer_idはより大きいrow_numberでスコアが出ているとみなせる
1365+ // player_scoreが同一player_id内ではrow_numの降順でソートされているので
1366+ // 現れたのが2回目以降のplayer_idはより大きいrow_numでスコアが出ているとみなせる
13671367 if _ , ok := scoredPlayerSet [ps .PlayerID ]; ok {
13681368 continue
13691369 }
0 commit comments