From 6073bb82a5e5b5d652631cb7f5a02ffd262c0c91 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Sat, 7 Dec 2024 19:22:08 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3bvs=E7=9A=84=E9=99=A40?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MySQL不支持NaN和Inf,所以使用0.0作为默认值。 --- back_end/saolei/videomanager/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back_end/saolei/videomanager/models.py b/back_end/saolei/videomanager/models.py index 42edd14..334252b 100644 --- a/back_end/saolei/videomanager/models.py +++ b/back_end/saolei/videomanager/models.py @@ -98,7 +98,7 @@ class VideoModel(models.Model): timems = models.PositiveIntegerField(default=DefaultRankingScores["timems"]) # 整数形式存储的毫秒数。 # 0-32767 bv = models.PositiveSmallIntegerField() - bvs = models.GeneratedField(expression = models.F('bv') / models.F('timems') * models.Value(1000), output_field = models.FloatField(), db_persist = True) + bvs = models.GeneratedField(expression = models.Case(models.When(timems=0,then=models.Value(0.0)), default=models.F('bv') / models.F('timems') * models.Value(1000), output_field = models.FloatField()), output_field = models.FloatField(), db_persist = True) # 暂时的解决方案 def __getattr__(self, name): From 43394d6951bfea0cd841804d402accf79b3a3cdf Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Sat, 7 Dec 2024 22:57:02 +0000 Subject: [PATCH 2/3] =?UTF-8?q?1bv=E5=BD=95=E5=83=8F=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back_end/saolei/videomanager/tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/back_end/saolei/videomanager/tests.py b/back_end/saolei/videomanager/tests.py index 7ce503c..06425fe 100644 --- a/back_end/saolei/videomanager/tests.py +++ b/back_end/saolei/videomanager/tests.py @@ -1,3 +1,14 @@ from django.test import TestCase +from userprofile.models import UserProfile +from .models import VideoModel, ExpandVideoModel # Create your tests here. + +class VideoManagerTestCase(TestCase): + def setUp(self): + self.user = UserProfile.objects.create(username='setUp', email='setUp@test.com') + + def test_zero_time(self): + expandvideo = ExpandVideoModel.objects.create(identifier='test', left=1, right=0, double=0, cl=1, left_s=0, right_s=0, double_s=0, cl_s=0, path=0, flag=0, flag_s=0, stnb=0, rqp=0, ioe=1, thrp=1, corr=1, ce=1, ce_s=0, op=1, isl=0, cell0=0, cell1=0, cell2=0, cell3=0, cell4=0, cell5=0, cell6=0, cell7=0, cell8=0) + video = VideoModel.objects.create(player=self.user, file='test.evf', video=expandvideo, state='a', software='e', level='b', mode='00', timems=0, bv=1) + self.assertEqual(video.bvs, 0) \ No newline at end of file From e1db03290cd61ca12ea27e921ddbc2ecb8913f5f Mon Sep 17 00:00:00 2001 From: Tianyi Pu <44583944+putianyi889@users.noreply.github.com> Date: Sat, 7 Dec 2024 22:58:55 +0000 Subject: [PATCH 3/3] Update backend.yml --- .github/workflows/backend.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 26ae840..a9ab709 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -55,5 +55,8 @@ jobs: - name: Flags run: python -m unittest tests.py -v + - name: Video Manager + run: python manage.py test videomanager + - name: Account Link run: python manage.py test accountlink