Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ランキング実装に失敗するとこうなるという例 / Broken ranking
Search
HASEGAWA Tomoki
April 24, 2019
Technology
640
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ランキング実装に失敗するとこうなるという例 / Broken ranking
PHP勉強会@東京 #134 の資料です。
HASEGAWA Tomoki
April 24, 2019
More Decks by HASEGAWA Tomoki
See All by HASEGAWA Tomoki
ファミコンでPHPを動かす / PHP on the Famicom
tomzoh
2
1.1k
3Dプリンタでコレはこう作る! - マルチディスプレイ用モニタアームマウンタの作り方 / Made with a 3D Printer: DIY Multi-Display Monitor Arm Mount
tomzoh
0
150
デシリアライゼーションを理解する / Inside Deserialization
tomzoh
0
1.2k
PHPer Book Revue: CPUの創りかた / How to Build a CPU
tomzoh
0
130
超入門3Dプリンタ: 生活を便利にするモノを作ろう / Getting Started with 3D Printing: Making small things that quietly improve your daily life.
tomzoh
0
110
最新ハードウェアの中の8ビットCPU / The Hidden Power of 8-Bit CPUs in Modern Hardware
tomzoh
0
330
PHPからはじめるコンピュータアーキテクチャ / From Scripts to Silicon: A Journey Through the Layers of Computing Hiroshima 2025 Edition
tomzoh
0
460
PHPからはじめるコンピュータアーキテクチャ / From Scripts to Silicon: A Journey Through the Layers of Computing
tomzoh
5
970
低レイヤを知りたいPHPerのためのCコンパイラ作成入門 完全版 / Building a C Compiler for PHPers Who Want to Dive into Low-Level Programming - Expanded
tomzoh
6
5k
Other Decks in Technology
See All in Technology
20260804_Q4AzureUpdateBite_FabricDataAgentの精度を高める設計.pdf
matayuuu
1
140
Apache Icebergインフラストラクチャ:ストレージ・カタログ・エンジンの選択肢とClouderaプラットフォームでの実装
tsugiyama
0
110
認知負荷をGemini で溶かす — GKE 基盤「Orbit」における AI エージェントの実践
sansantech
PRO
1
310
ホームラボ紹介
y_sera15
0
190
Bits AI を制するものは Datadog を制す / The player that controls Bits AI, controls Datadog
kaminashi
0
110
つくって納得、つかって実感! 大規模言語モデルことはじめ ver2.0
recruitengineers
PRO
4
1.7k
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.2k
AIペネトレーションテスト・ セキュリティ検証「AgenticSec」紹介資料
laysakura
2
9k
え?フロントエンドエンジニアの ワイがインフラも!?
puku0x
1
630
QAエンジニア起点で進める、SmartHRにおける信頼性向上について
kaomi_wombat
1
140
猫付きpingコマンドを自作
uyuki234
0
240
カートの信頼性を担保するWireMockを使ったe2eテスト
ykagano
0
340
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
450
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
650
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
620
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
490
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
490
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
Side Projects
sachag
455
43k
The Spectacular Lies of Maps
axbom
PRO
1
910
Transcript
୩ஐر ϥϯΩϯά࣮ʹ ࣦഊ͢Δͱ͜͏ͳΔͱ͍͏ྫ
୩ஐر !UPN[PI
ϥΠϑϫʔΫ ςοΫΧϯϑΝϨϯεӡӦࢀՃ 8FCJ04ΞϓϦ։ൃ Ϗʔϧ $16 ϨτϩήʔϜػ ిࢠ࡞
αοΧʔ؍ઓ ϨϯλϧΧʔτϨʔε ʜ σδλϧαʔΧεגࣜձࣾ ෭ஂ$50 !UPN[PI
None
None
8FC%FWFMPQNFOUXJUI 8&"3&)*3*/( IUUQXXXEHDJSDVTDPN 0NPUFTBOEP 5PLZP
ࢿྉެ։ࡁͰ͢ !UPN[PI
ࠓͷςʔϚ
None
ϥϯΩϯά࣮ʹ ࣦഊ͢Δͱ͜͏ͳΔͱ͍͏ྫ
None
None
None
None
None
None
SELECT tmp.attendee_id, tmp.score, tmp.rank FROM ( select attendee_id, score, @c:=@c+1
rank from challenge_players where conference_id = :conference_id and challenge_id = :challenge_id order by score desc, last_scored asc ) tmp ', [ 'conference_id' => $challenge->conference_id, 'challenge_id' => $challenge->id, ]) ->fetchAll('assoc');
SELECT tmp.attendee_id, tmp.score, tmp.rank FROM ( select attendee_id, score, @c:=@c+1
rank from challenge_players where conference_id = :conference_id and challenge_id = :challenge_id order by score desc, last_scored asc ) tmp ', [ 'conference_id' => $challenge->conference_id, 'challenge_id' => $challenge->id, ]) ->fetchAll('assoc');
SELECT tmp.attendee_id, tmp.score, tmp.rank FROM ( select attendee_id, score, @c:=@c+1
rank from challenge_players where conference_id = :conference_id and challenge_id = :challenge_id order by score desc, last_scored asc ) tmp ', [ 'conference_id' => $challenge->conference_id, 'challenge_id' => $challenge->id, ]) ->fetchAll('assoc'); είΞͷ߱ॱ
SELECT tmp.attendee_id, tmp.score, tmp.rank FROM ( select attendee_id, score, @c:=@c+1
rank from challenge_players where conference_id = :conference_id and challenge_id = :challenge_id order by score desc, last_scored asc ) tmp ', [ 'conference_id' => $challenge->conference_id, 'challenge_id' => $challenge->id, ]) ->fetchAll('assoc'); είΞͷ߱ॱ
SELECT tmp.attendee_id, tmp.score, tmp.rank FROM ( select attendee_id, score, @c:=@c+1
rank from challenge_players where conference_id = :conference_id and challenge_id = :challenge_id order by score desc, last_scored asc ) tmp ', [ 'conference_id' => $challenge->conference_id, 'challenge_id' => $challenge->id, ]) ->fetchAll('assoc'); είΞͷ߱ॱ ࠷ऴείΞ֫ಘ࣌ࠁͷঢॱ
SELECT tmp.attendee_id, tmp.score, tmp.rank FROM ( select attendee_id, score, @c:=@c+1
rank from challenge_players where conference_id = :conference_id and challenge_id = :challenge_id order by score desc, last_scored asc ) tmp ', [ 'conference_id' => $challenge->conference_id, 'challenge_id' => $challenge->id, ]) ->fetchAll('assoc'); είΞͷ߱ॱ ࠷ऴείΞ֫ಘ࣌ࠁͷঢॱ ಉͳΒઌʹͦͷʹୡͨ͠ํ͕উͪ
None
͜ΕͰ ʹͳͬͨ
͜ΕͰ ʹͳͬͨ ͜ΕͰ ʹ͍͍ͨ
$challengeInputsQuery = TableRegistry::get('ChallengeInputs')->find() ->where([ 'conference_id' => $challengePlayer->conference_id, 'challenge_id' => $challengePlayer->challenge_id,
'attendee_id' => $challengePlayer->attendee_id, ]); $scoreTotal = $challengeInputsQuery ->select([ 'score_total' => $challengeInputsQuery->func()->sum('score') ]) ->first(); if (! is_null($scoreTotal->score_total)){ $challengePlayer->score = intval($scoreTotal->score_total); $challengePlayer->last_scored = new Time(); } else { $challengePlayer->score = 0; }
$challengeInputsQuery = TableRegistry::get('ChallengeInputs')->find() ->where([ 'conference_id' => $challengePlayer->conference_id, 'challenge_id' => $challengePlayer->challenge_id,
'attendee_id' => $challengePlayer->attendee_id, ]); $scoreTotal = $challengeInputsQuery ->select([ 'score_total' => $challengeInputsQuery->func()->sum('score') ]) ->first(); if (! is_null($scoreTotal->score_total)){ $challengePlayer->score = intval($scoreTotal->score_total); $challengePlayer->last_scored = new Time(); } else { $challengePlayer->score = 0; } ਖ਼ղτʔΫϯ͡Όͳͯ͘ MBTU@TDPSFEΛߋ৽ͯ͠Δʜɻ
None
ແ೦
·ͱΊ
wϥϯΩϯάείΞτʔλϧΛϨίʔυʹ ॻ͍͓͚ͯൺֱత؆୯ʹ࡞ΕΔΑɻ ·ͱΊ
wϥϯΩϯάείΞτʔλϧΛϨίʔυʹ ॻ͍͓͚ͯൺֱత؆୯ʹ࡞ΕΔΑɻ wಉ͕ൃੜͨ࣌͠ͷϩδοΫΛॻ͘ͳΒςετ ͠Α͏Ͷɻ ·ͱΊ
wϥϯΩϯάείΞτʔλϧΛϨίʔυʹ ॻ͍͓͚ͯൺֱత؆୯ʹ࡞ΕΔΑɻ wಉ͕ൃੜͨ࣌͠ͷϩδοΫΛॻ͘ͳΒςετ ͠Α͏Ͷɻ w·͋Γ্͕͍͍͔ͬͨ͠ɻʢࢮʣ ·ͱΊ
͓ΘΓ !UPN[PI ͓ΘΓ
༨ஊ
None
None
GPSUFFKQ ϑ Υ ϧ ς wΧϯϑΝϨϯεӡӦࢧԉπʔϧ wεϙϯαʔืू ٻॻ࡞ʢ.JTPDB࿈ܞʣ ϩΰड͚औΓ Ұ੪ϝʔ
ϧ εϙϯαʔҰཡ"1* wϓϩϙʔβϧืूʢ$G1ʣ બఆ λΠϜςʔϒϧΤσΟλ Ұ੪ϝʔϧ ϓϩϙʔβϧҰཡ"1* λΠϜςʔϒϧදࣔ w4MBDL࿈ܞͯ͠εϙϯαʔԠืϓϩϙʔβϧԠื࣌ʹօͰΓ্͕Δ wνέοτൢച࣌&WFOUCSJUF࿈ܞͯ͠ࢀՃऀऔΓࠐΈ 5XJUUFSΞΠί ϯऔΓࠐΈ 23ίʔυੜ $47μϯϩʔυ ͦͷ··ҹ͞Μʹೖߘͯ͠ΞΠίϯ໊͖ࡳ wͦͷଞػೳ͍Ζ͍ΖʢνϟϨϯδػೳ͋ΔΑʣ
GPSUFFKQ ϑ Υ ϧ ς wЌӡ༻த w·͍ͩʹ͔ͬͨ͘Γ͔Γʹ͍͘ͱ͜Ζ͋Δ wόάେͳ͘ͳͬͨ w୩ͷΓ߹͍ͷํͰ͋Εൺֱత ҆৺ͯ͑͠ΔͷͰ
͝૬ஊ͍ͩ͘͞