1
0
mirror of synced 2025-02-22 12:40:15 +01:00

9 Commits

Author SHA1 Message Date
beerpsi
58a5177a30 use SQL's limit/offset pagination for nextIndex/maxCount requests (#185)
Instead of retrieving the entire list of items/characters/scores/etc. at once (and even store them in memory), use SQL's `LIMIT ... OFFSET ...` pagination so we only take what we need.

Currently only CHUNITHM uses this, but this will also affect maimai DX and O.N.G.E.K.I. once the PR is ready.

Also snuck in a fix for CHUNITHM/maimai DX's `GetUserRivalMusicApi` to respect the `userRivalMusicLevelList` sent by the client.

### How this works

Say we have a `GetUserCharacterApi` request:

```json
{
    "userId": 10000,
    "maxCount": 700,
    "nextIndex": 0
}
```

Instead of getting the entire character list from the database (which can be very large if the user force unlocked everything), add limit/offset to the query:

```python
select(character)
.where(character.c.user == user_id)
.order_by(character.c.id.asc())
.limit(max_count + 1)
.offset(next_index)
```

The query takes `maxCount + 1` items from the database to determine if there is more items than can be returned:

```python
rows = ...

if len(rows) > max_count:
    # return only max_count rows
    next_index += max_count
else:
    # return everything left
    next_index = -1
```

This has the benefit of not needing to load everything into memory (and also having to store server state, as seen in the [`SCORE_BUFFER` list](2274b42358/titles/chuni/base.py (L13)).)

Reviewed-on: https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/185
Co-authored-by: beerpsi <beerpsi@duck.com>
Co-committed-by: beerpsi <beerpsi@duck.com>
2024-11-16 19:10:29 +00:00
akanyan
f8db1e2149 ongeki: fix clearstatus type 2024-05-29 18:59:07 +09:00
Midorica
4c33dac96a Ongeki: fixed missing await under get_tech_count 2024-05-01 07:57:21 -04:00
Kumubou
1346bab911 Implement get_tech_count (it was stubbed out) 2024-04-17 00:45:05 +00:00
Hay1tsme
05586df08a move to async database 2024-01-09 14:42:17 -05:00
Hay1tsme
88a1462304 logger: change from warn to warning 2023-08-08 10:17:56 -04:00
Hay1tsme
a76bb94eb1 let black do it's magic 2023-03-09 11:38:58 -05:00
Midorica
3791b2b238 Adding Ongeki Bright Memory support 2023-03-03 00:00:22 -05:00
Hay1tsme
7e3396a7ff add back games, conform them to new title dispatch 2023-02-17 01:02:21 -05:00