Skip to content

Commit

Permalink
fix two bugs (nbsp and first or none) (#165)
Browse files Browse the repository at this point in the history
<!--- Please write your PR name in the present imperative tense.
Examples of that tense are: "Fix issue in the dispatcher where…",
"Improve our handling of…", etc." -->
<!-- For more information on Pull Requests, you can reference here:
https://success.vanillaforums.com/kb/articles/228-using-pull-requests-to-contribute
-->
## Describe Your Changes

- use `&nbsp;` as split()
- also get first session by session key or none

## Non-Obvious Technical Information


## Checklist Before Requesting a Review
- [x] The code runs successfully.

```commandline
2024-03-11 18:08:20 INFO:     172.21.0.1:48600 - "GET /games/session/w43ma/ HTTP/1.1" 307 Temporary Redirect
2024-03-11 18:08:20 INFO:     172.21.0.1:48586 - "GET /games/session/w43ma HTTP/1.1" 200 OK
```
  • Loading branch information
anisfeld authored Mar 11, 2024
1 parent 60445e1 commit 676171c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion prijateli_tree/app/routers/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from fastapi import APIRouter, Depends, Form, HTTPException, Request, Response
from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse
from fastapi.templating import Jinja2Templates
from sqlalchemy import desc
from sqlalchemy.orm import Session

from prijateli_tree.app.database import (
Expand Down Expand Up @@ -82,7 +83,8 @@ def choose_session_players(
session = (
db.query(GameSession)
.filter_by(session_key=session_key.lower())
.one_or_none()
.order_by(desc("created_at"))
.first()
)
if session is None:
return templates.TemplateResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
formData.append("player_" + numbers[i], parseInt(selectedRows[i][0]))
lang = selectedRows[i][1]
languageCounter[lang] = languageCounter[lang] ? languageCounter[lang] + 1 : 1;
groups = selectedRows[i][2].split('\n').map(s => s.trim());
groups = selectedRows[i][2].split('&nbsp;').map(s => s.trim());
for (const g of groups) {
if (g) { // g can be ""
groupCounter[g] = groupCounter[g] ? groupCounter[g] + 1 : 1;
Expand Down

0 comments on commit 676171c

Please sign in to comment.