Skip to content

Commit

Permalink
Dev (#217)
Browse files Browse the repository at this point in the history
* Update HomeView.vue (#211)

Co-authored-by: Tianyi Pu <[email protected]>

* 修改VideoModel (#212)

* 修改VideoModel1

- 增加GeneratedField: `cl_s`, `ce_s`, `ioe`, `thrp`, `corr`
- 删除ExpandVideoModel中如上五个域
- 更新view_utils.refresh_video以适应改动
- 增加view_utils.refresh_video的测试

* add flake8 tests

* Create flake8.yml

* Update backend.yml

* Update flake8.yml

* 格式化videomanager

* Update flake8.yml

* 格式化

* 格式化

* 格式化

* 格式化

* 格式化

* 格式化

* 格式化

* 格式化

* 格式化

* 忽略try except没有指定错误类型的问题

* fix

* 上传录像

* 增加flake8-commas测试

* fix

* 录像页、录像上传

* gzip压缩response (#213)

经测试,访问一个240录像用户主页,使用该middleware前响应大小34082B,使用后响应大小3683B

* 优化前端加载性能 (#214)

* 优化前端加载性能

- 个人主页的tab改用异步加载。#180 的改动取消了ms-toollib的异步引入,导致加载开销明显变大。此PR通过异步加载整个UploadView组件解决了这个问题。
- AccountLinkManager的子组件改用异步加载,未绑定账号的用户不会加载相应的子组件。
- vite打包使用gzip,使得加载内容减少了约三分之二

* Update package.json

* fix: 账号关联信息不显示 (#215)

---------

Co-authored-by: eee555 <[email protected]>
  • Loading branch information
putianyi889 and eee555 authored Jan 22, 2025
1 parent 42418ca commit ae4d179
Show file tree
Hide file tree
Showing 73 changed files with 759 additions and 637 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Back-end Code Style Check

on:
push:
branches:
- main # Adjust the branch name as needed
pull_request:
paths:
- 'back_end/saolei/**'

jobs:
check_flag:
runs-on: ubuntu-latest
defaults:
run:
working-directory: back_end/saolei

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.10' # Choose the Python version you want to use

- name: Install Dependencies
run: |
pip install flake8
pip install flake8-commas
pip install flake8-comprehensions
- name: Run Tests
run: |
python -m flake8 --ignore=E501,E722
2 changes: 1 addition & 1 deletion back_end/saolei/accountlink/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

class AccountLinkConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "accountlink"
name = "accountlink"
21 changes: 13 additions & 8 deletions back_end/saolei/accountlink/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
from django.db import models
from userprofile.models import UserProfile


class Platform(models.TextChoices):
MSGAMES = 'a', ('Authoritative Minesweeper')
SAOLEI = 'c', ('扫雷网')
WOM = 'w', ('Minesweeper.Online')


# 用于验证的队列
class AccountLinkQueue(models.Model):
platform = models.CharField(max_length=1, null=False, choices=Platform.choices)
Expand All @@ -33,18 +35,19 @@ class AccountLinkQueue(models.Model):
# Y - YouTube
# Z - Zhihu


# 扫雷网账号信息
class AccountSaolei(models.Model):
id = models.PositiveIntegerField(primary_key=True)
parent = models.OneToOneField(UserProfile, on_delete=models.CASCADE, related_name='account_saolei')
update_time = models.DateTimeField(auto_now=True)

name = models.CharField(max_length=10, default="") # 姓名,10应该够了吧
total_views = models.PositiveIntegerField(null=True) # 综合人气
name = models.CharField(max_length=10, default="") # 姓名,10应该够了吧
total_views = models.PositiveIntegerField(null=True) # 综合人气

beg_count = models.PositiveSmallIntegerField(null=True) # 初级录像数量
int_count = models.PositiveSmallIntegerField(null=True) # 中级录像数量
exp_count = models.PositiveSmallIntegerField(null=True) # 高级录像数量
beg_count = models.PositiveSmallIntegerField(null=True) # 初级录像数量
int_count = models.PositiveSmallIntegerField(null=True) # 中级录像数量
exp_count = models.PositiveSmallIntegerField(null=True) # 高级录像数量

# time纪录,单位毫秒
b_t_ms = models.PositiveIntegerField(null=True)
Expand All @@ -58,6 +61,7 @@ class AccountSaolei(models.Model):
e_b_cent = models.PositiveSmallIntegerField(null=True)
s_b_cent = models.PositiveSmallIntegerField(null=True)


class AccountMinesweeperGames(models.Model):
id = models.PositiveIntegerField(primary_key=True)
parent = models.OneToOneField(UserProfile, on_delete=models.CASCADE, related_name='account_msgames')
Expand All @@ -72,6 +76,7 @@ class AccountMinesweeperGames(models.Model):
# mouse_type = models.CharField(max_length=128) # 枚举
# mouse_model = models.CharField() # 用户自己随便填的,需要审查


class AccountWorldOfMinesweeper(models.Model):
id = models.PositiveIntegerField(primary_key=True)
parent = models.OneToOneField(UserProfile, on_delete=models.CASCADE, related_name='account_wom')
Expand All @@ -90,8 +95,8 @@ class AccountWorldOfMinesweeper(models.Model):
arena_ticket = models.PositiveIntegerField(null=True)
equipment = models.PositiveIntegerField(null=True)
part = models.PositiveIntegerField(null=True)
arena_point = models.PositiveSmallIntegerField(null=True) # 最高80

arena_point = models.PositiveSmallIntegerField(null=True) # 最高80
max_difficulty = models.PositiveIntegerField(null=True)
win = models.PositiveIntegerField(null=True)
last_season = models.PositiveSmallIntegerField(null=True)
Expand All @@ -115,4 +120,4 @@ class AccountWorldOfMinesweeper(models.Model):
# 主页只显示一个
# b_endurance = models.TimeField()
# i_endurance = models.TimeField()
# e_endurance = models.TimeField()
# e_endurance = models.TimeField()
11 changes: 6 additions & 5 deletions back_end/saolei/accountlink/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
from .utils import update_saolei_account, update_msgames_account, update_wom_account
from userprofile.models import UserProfile
import datetime
from unittest import skip, expectedFailure
from unittest import expectedFailure


class AccountLinkTestCase(TestCase):
def setUp(self):
user = UserProfile.objects.create(username='setUp', email='[email protected]')
AccountSaolei.objects.create(id=1,parent=user)
AccountSaolei.objects.create(id=1, parent=user)
AccountMinesweeperGames.objects.create(id=7872, parent=user)
AccountWorldOfMinesweeper.objects.create(id=1783173, parent=user)

def test_update_saolei(self):
account = AccountSaolei.objects.filter(id=1).first()
self.assertEqual(update_saolei_account(account, 0), '',)
self.assertEqual(update_saolei_account(account, 0), '')
account = AccountSaolei.objects.filter(id=1).first()
self.assertEqual(account.id, 1)
self.assertEqual(account.name, '张砷镓')
Expand All @@ -38,7 +39,7 @@ def test_update_msgames(self):
self.assertEqual(account.id, 7872)
self.assertEqual(account.name, 'Ze-En JU')
self.assertEqual(account.local_name, '鞠泽恩')
self.assertEqual(account.joined, datetime.date(2019,5,28))
self.assertEqual(account.joined, datetime.date(2019, 5, 28))

def test_update_wom(self):
account = AccountWorldOfMinesweeper.objects.filter(id=1783173).first()
Expand Down Expand Up @@ -85,4 +86,4 @@ def test_msgames_private_name(self):
account = AccountMinesweeperGames.objects.create(id=8371, parent=user)
self.assertEqual(update_msgames_account(account, 0), '')
self.assertEqual(account.name, 'Private')
self.assertEqual(account.local_name, 'None')
self.assertEqual(account.local_name, 'None')
2 changes: 1 addition & 1 deletion back_end/saolei/accountlink/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
path('update/', views.update_link),
path('verify/', views.verify_link),
path('unverify/', views.unverify_link),
]
]
Loading

0 comments on commit ae4d179

Please sign in to comment.