Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(BE): Temperature model #358

Open
wants to merge 46 commits into
base: dev/user-profile
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
991698b
feat: Add and link user profile page
jimin9038 Jan 8, 2022
3e669bf
feat: initialize user profile page
jimin9038 Jan 9, 2022
4f2e15a
Initialize Group Page.
DailyPS Feb 1, 2022
821dd0d
Change CSS.
DailyPS Feb 1, 2022
56d2011
change section title to common css
jimin9038 Feb 1, 2022
d48b8e6
Add Profile Submission in Profile Page (#290)
st42597 Feb 1, 2022
1788c95
Add profileSubmissionListAPI in Profile Page (#308)
st42597 Mar 1, 2022
f7a40bf
refactor: Rebase
goo314 Jan 10, 2022
898e0ab
fix: Delete routers of profile-contest
goo314 Jan 11, 2022
91b3329
feat: Add ProfileContest vue
goo314 Jan 11, 2022
ee6d032
feat: Publish user contest page
goo314 Jan 14, 2022
0ed9221
add: Add file in gitignore
goo314 Jan 14, 2022
3b39801
feat: Add Pagination component
goo314 Jan 21, 2022
5c816f3
feat: Add methods for each button in pagination vue
goo314 Jan 24, 2022
31cddcf
chore: Remove chart.js outside frontend folder
goo314 Jan 28, 2022
90ef7c8
fix: Show at most limit pages
goo314 Jan 28, 2022
d60dd19
style: Shorten style code
goo314 Jan 28, 2022
48c4bdc
fix: Add component communication(props, event)
goo314 Jan 28, 2022
fedb98c
style: Apply Pagination vue
goo314 Jan 28, 2022
2f2c883
style: Edit code style
goo314 Feb 6, 2022
0d99131
feat: Create USerContestAPI
goo314 Feb 8, 2022
4b1bad0
add: Calate and return user rank in UserContestAPI
goo314 Feb 9, 2022
679503c
style: Change code style
goo314 Feb 10, 2022
56326a5
add: Add rank field in ACMContestRank & Shorten UserContestAPI
goo314 Feb 10, 2022
4d10173
add: Connect UserContestAPI to ProfileContest page
goo314 Feb 14, 2022
4dce664
feat: Add sorting contests function in ProfileContest
goo314 Feb 20, 2022
48b4a94
fix: Connect sorting api to ProfileContest
goo314 Feb 20, 2022
1787bcb
feat: Add test for user-contest-api
goo314 Feb 26, 2022
bdf081e
feat: add contestprize model
jimin9038 Feb 25, 2022
2b67eea
style: Change code style
goo314 Mar 1, 2022
fa65414
migrate model change
jimin9038 Mar 2, 2022
ead63b1
resolve conflict: whiel rebase on master
jimin9038 Mar 2, 2022
bc3dff8
Fix UserContestAPITest
jimin9038 Mar 2, 2022
7dd4222
minor design change followed by tailwind css
jimin9038 Mar 2, 2022
1933ea5
init: temperature
st42597 Mar 15, 2022
6ee2690
fix: minor fix & add: rankAPI
st42597 Mar 15, 2022
51f9849
fix: foreign key
st42597 Mar 23, 2022
067f949
add: model migration
st42597 Mar 23, 2022
fdaacb3
fix: remigrate temperature model changes
jimin9038 Mar 23, 2022
652369d
fix: code style
st42597 Mar 23, 2022
c1cbe39
init: history
st42597 Mar 28, 2022
c47a7b4
fix: temperature
st42597 Apr 20, 2022
e19539a
add: temperature api
st42597 Apr 20, 2022
c43a561
add: new date temperature calculator
st42597 Apr 21, 2022
ac50b4d
fix: temperature calculate
st42597 Apr 26, 2022
f7d1d18
fix: delete trash file
st42597 Apr 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add: new date temperature calculator
  • Loading branch information
st42597 committed Apr 21, 2022
commit c43a561189da75f7328c7950f705a741dd1ee9c2
23 changes: 15 additions & 8 deletions backend/temperature/views.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
from utils.api import APIView, validate_serializer
from .models import ProblemScore, Temperature, SolvedProblem
from problem.models import Problem
from account.models import User
from .serializers import CreateTemperatureSerializer
import datetime

def createTemperature(user, date):
if Temperature.objects.filter(user=user, date=date).exists(): return
solved_problem = SolvedProblem.objects.filter(user=user)
solved_problem = list(solved_problem)
temp = 0
for t in solved_problem:
temp += ProblemScore.scores[t.problem.difficulty]
Temperature.objects.create(user=user, temperature=temp)

class TemperatureAPI(APIView):
def post(self, request):
id = request.GET.get("id")
if not id:
return self.error("Parameter error, id is required")
difficulty = Problem.objects.get(id=id).difficulty
print(ProblemScore.scores[difficulty])
date = datetime.date.today()
if not Temperature.objects.filter(user=request.user, date=date):
Temperature.objects.create(user=request.user)
createTemperature(request.user, date)
user_temp = Temperature.objects.get(user=request.user, date=date)
user_temp_qs = Temperature.objects.filter(user=request.user, date=date)
solved_problem = SolvedProblem.objects.filter(user=request.user, problem=id)
solved_problem = SolvedProblem.objects.filter(user=request.user, problem=Problem.objects.get(id=id))
if not solved_problem:
SolvedProblem.objects.create(user=request.user,
problem=Problem.objects.get(id=id))
@@ -27,11 +32,13 @@ def post(self, request):

def get(self, request):
date = datetime.date.today()
createTemperature(request.user, date)
user_temp = Temperature.objects.get(user=request.user, date=date)
if not user_temp:
data = "DB error, Data doesn't exist"
else: data = { "temperature": user_temp.temperature }
return self.success(data)
return self.error("DB error, Data doesn't exist")
else:
data = { "temperature": user_temp.temperature }
return self.success(data)

class RankAPI(APIView):
def get(self, request):