mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-11 02:17:28 +08:00
[Enhance] API & LinkPlay & something else
- Add song names for getting the score list (For API) - Try to ensure thread safety in Link Play (twice again) - Small change about database timeout - Have a try to use `nginx` and `gevent` (Yes. I ensure it works well. This will not be viewed as a formal and necessary update.)
This commit is contained in:
@@ -3,6 +3,8 @@ from functools import lru_cache
|
||||
from json import loads
|
||||
from time import time
|
||||
|
||||
from flask import url_for
|
||||
|
||||
from .constant import Constant
|
||||
from .error import NoAccess
|
||||
from .user import User
|
||||
@@ -118,7 +120,6 @@ class UserDownload:
|
||||
prefix += '/'
|
||||
return prefix + self.song_id + '/' + self.file_name + '?t=' + self.token
|
||||
else:
|
||||
from flask import url_for
|
||||
return url_for('download', file_path=self.song_id + '/' + self.file_name, t=self.token, _external=True)
|
||||
|
||||
@property
|
||||
|
||||
@@ -128,7 +128,7 @@ class Score:
|
||||
return self.rating
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {
|
||||
r = {
|
||||
"rating": self.rating,
|
||||
"modifier": self.modifier,
|
||||
"time_played": self.time_played,
|
||||
@@ -142,6 +142,9 @@ class Score:
|
||||
"difficulty": self.song.difficulty,
|
||||
"song_id": self.song.song_id
|
||||
}
|
||||
if self.song.song_name is not None:
|
||||
r["song_name"] = self.song.song_name
|
||||
return r
|
||||
|
||||
|
||||
class UserScore(Score):
|
||||
@@ -569,3 +572,12 @@ class UserScoreList:
|
||||
x = Sql(self.c).select('best_score', query=self.query)
|
||||
|
||||
self.scores = [UserScore(self.c, self.user).from_list(i) for i in x]
|
||||
|
||||
def select_song_name(self) -> None:
|
||||
'''为所有成绩中的song_id查询song_name'''
|
||||
if self.scores is None:
|
||||
return
|
||||
for score in self.scores:
|
||||
self.c.execute(
|
||||
'''select name from chart where song_id = ?''', (score.song.song_id,))
|
||||
score.song.song_name = self.c.fetchone()[0]
|
||||
|
||||
@@ -8,6 +8,7 @@ class Chart:
|
||||
self.c = c
|
||||
self.set_chart(song_id, difficulty)
|
||||
self.defnum: int = None
|
||||
self.song_name: str = None
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {
|
||||
|
||||
@@ -19,7 +19,7 @@ class Connect:
|
||||
self.file_path = file_path
|
||||
|
||||
def __enter__(self):
|
||||
self.conn = sqlite3.connect(self.file_path)
|
||||
self.conn = sqlite3.connect(self.file_path, timeout=10)
|
||||
self.c = self.conn.cursor()
|
||||
return self.c
|
||||
|
||||
|
||||
Reference in New Issue
Block a user