fix: unintended changes in the leaderboard JSON model

This commit is contained in:
sBubshait 2025-08-07 11:15:33 +03:00
parent 8541eb4a6e
commit 5e5c6c7346
3 changed files with 148 additions and 143 deletions

View File

@ -70,10 +70,9 @@ public class PuzzleController {
@GetMapping("/leaderboard") @GetMapping("/leaderboard")
@Operation(summary = "Get daily leaderboard", description = "Returns leaderboard with 9am cutoff logic (before 9am shows yesterday, from 9am shows today)") @Operation(summary = "Get daily leaderboard", description = "Returns leaderboard with 9am cutoff logic (before 9am shows yesterday, from 9am shows today)")
public ResponseEntity<ApiResponse<Map<String, Object>>> getLeaderboard() { public ResponseEntity<ApiResponse<List<LeaderboardEntry>>> getLeaderboard() {
try { try {
List<PuzzleAttempt> attempts = puzzleService.getTodaysLeaderboard(); List<PuzzleAttempt> attempts = puzzleService.getTodaysLeaderboard();
String leaderboardInfo = puzzleService.getLeaderboardDateInfo();
List<LeaderboardEntry> leaderboard = attempts.stream() List<LeaderboardEntry> leaderboard = attempts.stream()
.filter(attempt -> attempt.isSolved()) .filter(attempt -> attempt.isSolved())
@ -87,12 +86,7 @@ public class PuzzleController {
)) ))
.collect(Collectors.toList()); .collect(Collectors.toList());
Map<String, Object> response = Map.of( return ResponseEntity.ok(ApiResponse.success(leaderboard));
"leaderboard", leaderboard,
"dateInfo", leaderboardInfo
);
return ResponseEntity.ok(ApiResponse.success(response));
} catch (RuntimeException e) { } catch (RuntimeException e) {
return ResponseEntity.ok(ApiResponse.error(e.getMessage())); return ResponseEntity.ok(ApiResponse.error(e.getMessage()));
} }

View File

@ -172,15 +172,4 @@ public class PuzzleService {
return puzzleAttemptRepository.findByPuzzleOrderBySubmittedAtAsc(puzzleOpt.get()); return puzzleAttemptRepository.findByPuzzleOrderBySubmittedAtAsc(puzzleOpt.get());
} }
public String getLeaderboardDateInfo() {
LocalDateTime riyadhNow = getRiyadhNow();
LocalDate leaderboardDate = getLeaderboardDate();
LocalDate today = riyadhNow.toLocalDate();
if (leaderboardDate.equals(today)) {
return "Today's Leaderboard (from 9:00 AM Riyadh time)";
} else {
return "Yesterday's Leaderboard (before 9:00 AM Riyadh time)";
}
}
} }

View File

@ -383,9 +383,19 @@ class _WordlePageState extends State<WordlePage> with TickerProviderStateMixin {
child: Container(height: 1, color: Colors.grey[200]), child: Container(height: 1, color: Colors.grey[200]),
), ),
), ),
body: Column( body: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) {
double screenHeight = constraints.maxHeight;
double keyboardHeight = (gameWon || gameLost) ? 200 : 200; // Estimated heights
double availableHeight = screenHeight - keyboardHeight;
return Column(
children: [ children: [
// Game Grid Section
Expanded( Expanded(
child: Container(
height: availableHeight,
child: Center( child: Center(
child: Container( child: Container(
constraints: BoxConstraints(maxWidth: 350), constraints: BoxConstraints(maxWidth: 350),
@ -511,14 +521,26 @@ class _WordlePageState extends State<WordlePage> with TickerProviderStateMixin {
), ),
), ),
), ),
// Keyboard or completion message ),
// Spacer between grid and keyboard
SizedBox(height: 16),
// Keyboard or completion message section
Container( Container(
padding: EdgeInsets.all(8), constraints: BoxConstraints(
minHeight: 200,
maxHeight: 250,
),
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 16),
child: (gameWon || gameLost) child: (gameWon || gameLost)
? _buildCompletionMessage() ? _buildCompletionMessage()
: _buildKeyboard(), : _buildKeyboard(),
), ),
// Bottom padding to ensure keyboard isn't at the very bottom
SizedBox(height: MediaQuery.of(context).padding.bottom + 8),
], ],
);
},
),
), ),
), ),
), ),