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

hotfix/BE-38: new_bids reset #397

Merged
merged 1 commit into from
Dec 26, 2022
Merged
Changes from all commits
Commits
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
25 changes: 16 additions & 9 deletions App/backend/api/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

levelThreshold = 10

profilecount = 0

@ swagger_auto_schema(
method='get',
operation_description="Returns username, email, name, surname, about section, location and URL to the profile picture of the user with the given ID. isFollowed field returns True if currently logged-in user follows the given user. Defaults to False if user is a guest user.",
Expand Down Expand Up @@ -195,12 +197,17 @@ def profile_me_api(request):
user.calculateLevel()
serializer = UserProfileSerializer(user)
mydata = serializer.data
user.new_bid_flag = False
user.save()

global profilecount
newbids = NewBids.objects.get(user=user)
mydata.update(NewBidsSerializer(newbids).data)
newbids.new_bids.clear()
newbids.save()
mydata.update(NewBidsSerializer(newbids).data)
if profilecount%2 == 1:
user.new_bid_flag = False
user.save()
newbids.new_bids.clear()
newbids.save()

profilecount = profilecount + 1

return Response(mydata, status=status.HTTP_200_OK)
elif (request.method == "PUT"):
Expand Down Expand Up @@ -270,13 +277,13 @@ def LevelView(request):
else:
#level calculation is not dynamic, meaning even if levelThreshold is later raised, gained is_level2 status is not lost
comments = Comment.objects._mptt_filter(commented_by=user).count()
print(comments)
#print(comments)
artitems = ArtItem.objects.filter(owner=user).count()
print(artitems)
#print(artitems)
visits = History.objects.filter(user=user).count()
print(visits)
#print(visits)
result = 0.8*artitems + 0.1*comments + 0.02*visits
print(result)
#print(result)
if(result>levelThreshold and not user.is_level2):
user.is_level2 = True
user.save()
Expand Down