Skip to content

Commit

Permalink
Merge pull request #75 from Lost-MSth/dev
Browse files Browse the repository at this point in the history
Update to v2.10.1
  • Loading branch information
Lost-MSth authored Nov 10, 2022
2 parents 65aed56 + e3d5c19 commit bd9eb28
Show file tree
Hide file tree
Showing 17 changed files with 401 additions and 168 deletions.
58 changes: 25 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,31 @@ It is just so interesting. What it can do is under exploration.
> Tips: When updating, please keep the original database in case of data loss.

### **2022.11.5**
**修复一长期BUG,影响到自2022.7.4以来所有版本(表现为数据库锁以及服务端运行缓慢),请拉取或下载`master`分支最新提交**

**Fix a long-term bug that affects all versions since Jul/4/2022 (shown as database lock and slow running). Please pull or download the latest commit from the `master` branch.**

### Version 2.10.0
- 适用于Arcaea 4.1.0版本 For Arcaea 4.1.0
- 新搭档 **咲姬** 已解锁 Unlock the character **Saki**.
- 新搭档 **刹那** 已解锁 Unlock the character **Setsuna**.
- 完善了日志系统 Improve the log system.
- 现在可以利用`songlist`确保`3.aff`以外文件不被下载 Now you can use `songlist` to ensure that files other than `3.aff` should not be downloaded. [#60](https://github.com/Lost-MSth/Arcaea-server/issues/60)
- 适配v4.0.0以下版本的客户端云存档 Ensure that the clients under v4.0.0 can upload the cloud save.
- 优化数据库索引 Optimize database indices.
- 尝试确保LinkPlay服务器的线程安全,现在此功能将作为独立服务端 Try to ensure thread safety in LinkPlay server. Now this function will be served as an independent server.
- 对API接口的分数列表添加歌曲名 Add song names for getting the score list in API.
- 为下载错误增添HTTP状态码 Add HTTP status code when meeting download error.

- 修复iOS客户端因世界模式地图数据闪退的问题 Fix a bug when world maps' data don't have some unnecessary parts the client of iOS may break down.
- 修复API接口无数据`GET`请求导致报错的问题 Fix a bug that `GET` requests without data will report an error in API. [#50](https://github.com/Lost-MSth/Arcaea-server/issues/50)
- 修复`aggregate`请求无法捕获内部错误的问题 Fix a bug that `aggregate` requests will get an error when the inner function raises an error.
- 修复因错误设置主键导致课程模式谱面无法相同的问题 Fix a bug that the charts of a course cannot be the same because of the incorrect primary keys.
- 修复无谱面数据时世界排名分计算出错的问题 Fix a bug that global ranking scores cannot be calculated if there are no chart in the database. [#61](https://github.com/Lost-MSth/Arcaea-server/issues/61)
- 修复条件满足但隐藏段位依然无法解锁的问题 Fix a bug that the hidden courses cannot appear even if their requirements are satisfied.
- 修复Finale挑战中某些无法解锁的问题 Fix a bug that something of the finale challenge cannot be unlocked.
- 修复用户物品数量无法为0的问题,此问题导致了一些购买操作异常 Fix a bug that the users' items will not be zero, which will disturb some purchase operations.
- 修复角色等级能超过最大等级的问题 Fix a bug that the level of the character can exceed the max level.
- 修复使用`以太之滴`升级角色时应答不正确的问题 Fix a bug that the response is incorrect when upgrading the characters by `generic core`.
- 修复`源韵强化`数值显示不正确的问题 Fix a bug that the `prog boost` shows the incorrect value.
- 修复世界模式奖励可能被重复发放的问题 Fix a bug that the rewards can be get repeatedly in World Mode.
- 修复世界Boss的第二管血量无法削减的问题 Fix a bug that second tube of blood of the world boss won't change.
- 修复我的排名显示不正确的问题 Fix a bug that `my rank` doesn't work correctly.
- 修复在歌曲结束后无法及时轮换房主的问题 Fix a bug that the room host will be changed late when finishing a song.

### Version 2.10.1
- 适用于Arcaea 4.1.4版本 For Arcaea 4.1.4
- 新搭档 **天音** 已解锁 Unlock the character **Amane**.
-**天音**技能提供支持 Add support for the skill of **Amane**.
- 现在配置文件可以是含有部分选项的文件或模块 At present the setting file can be a module or a file with some of options.
- 添加`waitress``gevent`的部署方案支持,并支持日志记录 Add deployment mode `waitress` and `gevent`, and add support for the info log recording of them.
-`songlist`添加解析器以指定可下载的文件 Add a parser for `songlist` to specify downloadable files.
- 重构数据库初始化和数据迁移部分 Code refactoring for database initialization and migration.
- 限制用户下载频率将使用第三方限制器,替代数据库 Add a custom limiter and use it for limiting users' download rate instead of using database.
> 现在需要`limits`模块
> Now `limits` module is required.
- 为登录和API登录添加限制器 Add limiter for login and API login.
- `sqlite3`数据库调整为WAL模式并增大缓存 Change journal mode to WAL and enlarge cache size for `sqlite3` database.
- 将下载token放入内存中而不是文件数据库中 Put download token in memory database instead of filesystem database.
- 加速`best_score`表多次查询,表现为歌曲排行榜查询性能提升 Accelerate multiple querying in `best_score` table, which results in performance improvement of song ranklist query.
- 优化歌曲下载部分 Make some optimization for downloading songs.
- **修复更新recent 10时可能出现的死循环问题 Fix a bug that there is a endless loop in calculating recent 10 updating.** (due to 6fcca179182775615115cdb255b3a8223831a8a0)
- 修复课题模式成绩没有rating的问题 Fix a bug that scores in course mode cannot calculate rating.
- 修正搭档数值 Fix a character's value.
- 邮箱长度最大限制提升到64 Change the email max length to 64.
- 新增API接口来获取用户身份与权限 Add a method of API for getting users' roles and powers.
- 新增API接口来修改用户信息 Add a method of API to change the user's info.
- 为API的`GET`请求添加`query`参数支持 Add support for the `query` param in API's `GET` requests.
- 修复API的`best30`接口曲目无数据导致出错的问题 Fix a bug that `best30` of API cannot have scores whose songs are not in database.
- 修复API的`recent30`接口用户成绩数量不足导致出错的问题 Fix a bug that users with no recent scores cannot get `recent30` via API.

## 运行环境与依赖 Running environment and requirements
- Windows/Linux/Mac OS/Android...
Expand Down
4 changes: 2 additions & 2 deletions latest version/api/api_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def wrapped_view(*args, **kwargs):
json_data = loads(
b64decode(request.args['query']).decode())
else:
return view(data, *args, **kwargs)
json_data = {}

for key in required_keys:
if key not in json_data:
return error_return(PostError('Missing parameter: ' + key, api_error_code=-100))
return error_return(PostError(f'Missing parameter: {key}', api_error_code=-100))
data[key] = json_data[key]

for key in optional_keys:
Expand Down
26 changes: 14 additions & 12 deletions latest version/api/api_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@

CODE_MSG = {
0: '',
-1: 'See status code',
-1: 'See status code', # 基础错误
-2: 'No data',
-3: 'No data or user',
-4: 'No user_id',
-100: 'Wrong post data',
-101: 'Wrong data type',
-102: 'Wrong query parameter',
-103: 'Wrong sort parameter',
-104: 'Wrong sort order parameter',
-200: 'No permission',
-3: 'No data or user', # 不确定是无数据还是无用户
-100: 'Invalid post data', # 1xx数据错误
-101: 'Invalid data type',
-102: 'Invalid query parameter',
-103: 'Invalid sort parameter',
-104: 'Invalid sort order parameter',
-105: 'Invalid URL parameter',
-110: 'Invalid user_id',
-200: 'No permission', # 2xx用户相关错误
-201: 'Wrong username or password',
-202: 'User is banned',
-203: 'Username exists',
-204: 'Email address exists',
-205: 'Too many login attempts',
-203: 'Too many login attempts',
-210: 'Username exists',
-211: 'Email address exists',
-212: 'User code exists',
-999: 'Unknown error'
}

Expand Down
50 changes: 44 additions & 6 deletions latest version/api/users.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from core.error import InputError, NoAccess, NoData
from core.score import Potential, UserScoreList
from core.sql import Connect, Query, Sql
from core.user import UserInfo, UserRegister
from core.user import UserChanger, UserInfo, UserRegister
from core.api_user import APIUser
from flask import Blueprint, request

Expand Down Expand Up @@ -66,7 +66,7 @@ def users_get(data, user):
def users_user_get(user, user_id):
'''查询用户信息'''
if user_id <= 0:
return error_return(InputError(api_error_code=-4))
return error_return(InputError(api_error_code=-110))
# 查别人需要select权限
if user_id != user.user_id and not user.role.has_power('select'):
return error_return(NoAccess('No permission', api_error_code=-1), 403)
Expand All @@ -76,13 +76,45 @@ def users_user_get(user, user_id):
return success_return(u.to_dict())


@bp.route('/<int:user_id>', methods=['PUT'])
@role_required(request, ['change'])
@request_json_handle(request, optional_keys=['name', 'password', 'user_code', 'ticket', 'email'])
@api_try
def users_user_put(data, user, user_id):
'''修改一个用户'''
with Connect() as c:
u = UserChanger(c, user_id)
r = {}
r['user_id'] = user_id
if 'name' in data:
u.set_name(data['name'])
r['name'] = u.name
if 'password' in data:
u.set_password(data['password'])
r['password'] = u.hash_pwd
if 'email' in data:
u.set_email(data['email'])
r['email'] = u.email
if 'user_code' in data:
u.set_user_code(data['user_code'])
r['user_code'] = u.user_code
if 'ticket' in data:
if not isinstance(data['ticket'], int):
raise InputError('Ticket must be int')
u.ticket = data['ticket']
r['ticket'] = u.ticket
if r:
u.update_columns(d=r)
return success_return(r)


@bp.route('/<int:user_id>/b30', methods=['GET'])
@role_required(request, ['select', 'select_me'])
@api_try
def users_user_b30_get(user, user_id):
'''查询用户b30'''
if user_id <= 0:
return error_return(InputError(api_error_code=-4))
return error_return(InputError(api_error_code=-110))
# 查别人需要select权限
if user_id != user.user_id and not user.role.has_power('select'):
return error_return(NoAccess('No permission', api_error_code=-1), 403)
Expand All @@ -91,6 +123,9 @@ def users_user_b30_get(user, user_id):
x = UserScoreList(c, UserInfo(c, user_id))
x.query.limit = 30
x.select_from_user()
if not x.scores:
raise NoData(
f'No best30 data of user `{user_id}`', api_error_code=-3)
x.select_song_name()
r = x.to_dict_list()
rating_sum = sum([i.rating for i in x.scores])
Expand All @@ -104,7 +139,7 @@ def users_user_b30_get(user, user_id):
def users_user_best_get(data, user, user_id):
'''查询用户所有best成绩'''
if user_id <= 0:
return error_return(InputError(api_error_code=-4))
return error_return(InputError(api_error_code=-110))
# 查别人需要select权限
if user_id != user.user_id and not user.role.has_power('select'):
return error_return(NoAccess('No permission', api_error_code=-1), 403)
Expand All @@ -113,6 +148,9 @@ def users_user_best_get(data, user, user_id):
x = UserScoreList(c, UserInfo(c, user_id))
x.query.from_dict(data)
x.select_from_user()
if not x.scores:
raise NoData(
f'No best score data of user `{user_id}`', api_error_code=-3)
r = x.to_dict_list()
return success_return({'user_id': user_id, 'data': r})

Expand All @@ -124,7 +162,7 @@ def users_user_r30_get(user, user_id):
'''查询用户r30'''

if user_id <= 0:
return error_return(InputError(api_error_code=-4))
return error_return(InputError(api_error_code=-110))
# 查别人需要select权限
if user_id != user.user_id and not user.role.has_power('select'):
return error_return(NoAccess('No permission', api_error_code=-1), 403)
Expand All @@ -141,7 +179,7 @@ def users_user_role_get(user, user_id):
'''查询用户role和powers'''

if user_id <= 0:
return error_return(InputError(api_error_code=-4))
return error_return(InputError(api_error_code=-110))

if user_id == user.user_id:
return success_return({'user_id': user.user_id, 'role': user.role.role_id, 'powers': [i.power_id for i in user.role.powers]})
Expand Down
4 changes: 2 additions & 2 deletions latest version/core/constant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .config_manager import Config

ARCAEA_SERVER_VERSION = 'v2.10.0.3'
ARCAEA_SERVER_VERSION = 'v2.10.1'


class Constant:
Expand Down Expand Up @@ -96,6 +96,6 @@ class Constant:
]

DATABASE_MIGRATE_TABLES = ['user', 'friend', 'best_score', 'recent30', 'user_world', 'item', 'user_item', 'purchase', 'purchase_item', 'user_save',
'login', 'present', 'user_present', 'present_item', 'redeem', 'user_redeem', 'redeem_item', 'api_login', 'chart', 'user_course', 'user_char']
'login', 'present', 'user_present', 'present_item', 'redeem', 'user_redeem', 'redeem_item', 'api_login', 'chart', 'user_course', 'user_char', 'user_role']

UPDATE_WITH_NEW_CHARACTER_DATA = Config.UPDATE_WITH_NEW_CHARACTER_DATA
Loading

0 comments on commit bd9eb28

Please sign in to comment.