Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
hu8813 committed Apr 23, 2024
1 parent 038dfc9 commit afac243
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions srcs/backend/myapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def get_friends(request):
return JsonResponse({'error': 'User not found'}, status=404)
except Exception as e:
return JsonResponse({'error': str(e)}, status=400)

def unblock_user(request):
try:
token = request.headers.get('Authorization', '').split('Bearer ')[-1]
Expand Down Expand Up @@ -308,6 +309,7 @@ def fetch_achievements(request):
'games_lost': achievements.games_lost,
'tournaments_won': achievements.tournaments_won,
'favorite_game': achievements.favorite_game,

}

return JsonResponse(data)
Expand Down Expand Up @@ -373,8 +375,8 @@ def submit_feedback(request):
@csrf_exempt
def get_online_users(request):
try:
time_threshold = timezone.now() - timedelta(minutes=42)
time_threshold = timezone.now() - timedelta(seconds=settings.SESSION_COOKIE_AGE) + timedelta(minutes=42)

active_sessions = Session.objects.filter(expire_date__gte=time_threshold)

online_user_ids = set()
Expand Down
5 changes: 4 additions & 1 deletion srcs/frontend/js/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ async function fetchAndDisplayFriends() {
friendElement.classList.add('friend');
friendElement.style.marginBottom = '10px';

// Create an element to display friend's online status
const statusIndicator = document.createElement('div');
statusIndicator.classList.add('status-indicator');
statusIndicator.style.backgroundColor = friend.status === 'online' ? 'green' : 'gray';
Expand Down Expand Up @@ -296,6 +295,10 @@ async function fetchAndDisplayProfile() {
if (emailElement) {
emailElement.textContent = email;
}
const scorelement = document.getElementById('scorerate');
if (scorelement) {
scorelement.textContent = score;
}

if (document.getElementById('changePhoto')) {
document.getElementById('changePhoto').addEventListener('click', function () {
Expand Down
5 changes: 3 additions & 2 deletions srcs/frontend/views/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@

</div>

<div class="achievments" style="align-items: center;">
<div class="category" id="achievementsTitle">Achievements</div>
<div class="achievments" style="align-items: center ;">
<div class="category" id="achievementsTitle" style="align-items: center;">Achievements</div>
<span id="totalgames">Total Games Played</span>: <div id="total-played">0</div>
<span id="totalwins">Total Wins</span>: <div id="total-won"> 0</div>
<span id="totalloses">Total Losses</span>: <div id="total-lost">0</div>
<span id="WinningRatelbl">Winning Rate</span>: <div id="winning-rate">0</div>
<span id="scorelbl">Score</span>: <div id="scorerate">0</div>
</div>

</div>

0 comments on commit afac243

Please sign in to comment.