Skip to content

Commit

Permalink
feat(clans): add statistic that show Reports for the last 10 days by …
Browse files Browse the repository at this point in the history
…Diary's XP
  • Loading branch information
Hojagulyyev committed Dec 7, 2023
1 parent bf962b1 commit 9eec33e
Show file tree
Hide file tree
Showing 5 changed files with 413 additions and 201 deletions.
6 changes: 6 additions & 0 deletions apps/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class Account(models.Model):
def __str__(self):
return self.user.username

def get_xp_daily_report(self):
return [
diary.get_earned_xp()
for diary in self.diaries.all()[:10]
]

def get_full_name(self):
return f"{self.user.first_name} {self.user.last_name}"

Expand Down
2 changes: 2 additions & 0 deletions apps/clans/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib.auth.decorators import login_required
from django.contrib.postgres.aggregates import ArrayAgg
from django.shortcuts import render
from django.db.models import Count

Expand Down Expand Up @@ -41,6 +42,7 @@ def overview(request):
context = {
"accounts": paginated_account_queryset,
"diary_commits_count": diary_commits_count,
"top_accounts": account_queryset[:4],
}

return render(request, "clans/overview.html", context)
15 changes: 15 additions & 0 deletions apps/xps/templatetags/level_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
10: ("#ff0000", "#00aaff"),
}

STATISTIC_COLOR_DESIGN = {
1: "#4ff461",
2: "#08b8f1",
3: "#7750f8",
}


@register.filter(name="get_color_index_by_level")
def get_color_index_by_level(level: int):
Expand All @@ -43,3 +49,12 @@ def get_level_color_by_level(level, gradient_index=0):
@register.filter(name='range_list')
def range_list(number):
return range(1, number + 1)


@register.filter(name="get_statistic_color_by_color_index")
def get_statistic_color_by_color_index(color_index):

if color_index > len(STATISTIC_COLOR_DESIGN):
color_index = list(STATISTIC_COLOR_DESIGN.keys())[-1]

return STATISTIC_COLOR_DESIGN[color_index]
26 changes: 24 additions & 2 deletions static/js/global/global.charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,14 @@ app.querySelector('#ve-monthly-report-chart', function (el) {
app.querySelector('#rc-yearly-report-chart', function (el) {
const datasetData1 = [119, 142, 110, 122, 163, 139, 143, 110, 141, 121, 139, 190],
datasetData2 = [98, 65, 132, 78, 112, 82, 100, 80, 100, 58, 48, 139],
datasetData3 = [78, 25, 142, 38, 122, 52, 90, 80, 100, 58, 28, 138],
canvas = el[0],
ctx = canvas.getContext('2d'),
chartData = {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'Reactions',
label: 'Commits',
data: datasetData1,
fill: false,
lineTension: 0,
Expand All @@ -388,7 +389,7 @@ app.querySelector('#rc-yearly-report-chart', function (el) {
pointHitRadius: 10
},
{
label: 'Comments',
label: 'Commits',
data: datasetData2,
fill: false,
lineTension: 0,
Expand All @@ -407,6 +408,27 @@ app.querySelector('#rc-yearly-report-chart', function (el) {
pointHoverBorderWidth: 4,
pointRadius: 5,
pointHitRadius: 10
},
{
label: 'Commits',
data: datasetData3,
fill: false,
lineTension: 0,
borderWidth: 4,
borderColor: "#6808f1",
borderCapStyle: 'bevel',
borderDash: [],
borderDashOffset: 0,
borderJoinStyle: 'bevel',
pointBorderColor: "#6808f1",
pointBackgroundColor: "#1d2333",
pointBorderWidth: 4,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#1d2333",
pointHoverBorderColor: "#6808f1",
pointHoverBorderWidth: 4,
pointRadius: 5,
pointHitRadius: 10
}
]
},
Expand Down
Loading

0 comments on commit 9eec33e

Please sign in to comment.