From c570910fcba8bfd8bcc1a932b692370d7f898beb Mon Sep 17 00:00:00 2001 From: Hojagulyyev Date: Thu, 7 Dec 2023 20:55:05 +0500 Subject: [PATCH] feat(clans): add dates to 10 days report --- apps/xps/templatetags/level_design.py | 18 +++++++++++----- scripts/env.sh | 10 +++++++++ scripts/git/git_merge_dev_push_main.sh | 30 ++++++++++++++++++++++++++ templates/clans/overview.html | 2 +- 4 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 scripts/env.sh create mode 100644 scripts/git/git_merge_dev_push_main.sh diff --git a/apps/xps/templatetags/level_design.py b/apps/xps/templatetags/level_design.py index 1af44e2..11f516f 100644 --- a/apps/xps/templatetags/level_design.py +++ b/apps/xps/templatetags/level_design.py @@ -1,3 +1,5 @@ +import datetime + from django import template from rp2.business_logic import LEVEL_STEP_THAT_CHANGE_COLOR_DESIGN @@ -46,11 +48,6 @@ def get_level_color_by_level(level, gradient_index=0): return get_level_color_by_color_index(color_index, gradient_index) -@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): @@ -58,3 +55,14 @@ def get_statistic_color_by_color_index(color_index): color_index = list(STATISTIC_COLOR_DESIGN.keys())[-1] return STATISTIC_COLOR_DESIGN[color_index] + + +@register.filter(name='range_list') +def range_list(number): + return range(1, number + 1) + + +@register.filter() +def remove_days(days): + new_date = datetime.date.today() - datetime.timedelta(days=days) + return new_date diff --git a/scripts/env.sh b/scripts/env.sh new file mode 100644 index 0000000..9b803cb --- /dev/null +++ b/scripts/env.sh @@ -0,0 +1,10 @@ +# config +BASE_DIR="rp2" + +# ansi +YELLOW='\e[0;33m' +RED='\033[0;31m'; +LIGHT_RED='\033[1;31m'; +GREEN='\033[0;32m'; +LIGHT_GREEN='\033[1;32m'; +NO_COLOR='\033[0m'; diff --git a/scripts/git/git_merge_dev_push_main.sh b/scripts/git/git_merge_dev_push_main.sh new file mode 100644 index 0000000..4ea3617 --- /dev/null +++ b/scripts/git/git_merge_dev_push_main.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +. scripts/env.sh + +current_directory=$( pwd ); +current_branch=$(git branch --show-current) + +# ===== VALIDATION ===== + +if ! [ "$current_branch" == "dev" ]; then + printf "${YELLOW}The current branch must be dev${NO_COLOR}\n" + printf "${LIGHT_RED}Failed${NO_COLOR}\n" + return +fi + +if ! [[ "$current_directory" == *$BASE_DIR ]]; then + printf "${YELLOW}The current directory must be $BASE_DIR${NO_COLOR}\n" + printf "${LIGHT_RED}Failed${NO_COLOR}\n" + return +fi + +# ===== PROCESS ===== + +git checkout main +git pull origin main +git merge dev +git push origin main +git checkout dev + +printf "${LIGHT_GREEN}Succeed${NO_COLOR}\n" \ No newline at end of file diff --git a/templates/clans/overview.html b/templates/clans/overview.html index 2a83f72..4e986f8 100644 --- a/templates/clans/overview.html +++ b/templates/clans/overview.html @@ -353,7 +353,7 @@

Overview

canvas = el[0], ctx = canvas.getContext('2d'), chartData = { - labels: ['1', '2', '3', '4', '5', '6', '7', '8', 'yesterday', 'today', 'tomorrow'], + labels: ['{{ 9|remove_days }}', '{{ 8|remove_days }}', '{{ 7|remove_days }}', '{{ 6|remove_days }}', '{{ 5|remove_days }}', '{{ 4|remove_days }}', '{{ 3|remove_days }}', '{{ 2|remove_days }}', 'yesterday', 'today', 'tomorrow'], datasets: [ {% for account in top_accounts %} {