diff --git a/app/assets/v2/css/results.css b/app/assets/v2/css/results.css index b94fbc848d1..7ec81ae75cf 100644 --- a/app/assets/v2/css/results.css +++ b/app/assets/v2/css/results.css @@ -4,7 +4,7 @@ margin-right: 10px; } -.navbar{ +.navbar { background-color: #0d023b; } @@ -160,7 +160,6 @@ p.single-stat__fineprint { color: var(--gc-dark-grey); } - .bounty-status-breakdown { display: flex; align-items: center; @@ -228,6 +227,16 @@ p.single-stat__fineprint { height: auto; } +.hackathon-breakdown div { + width: 250px; + display: inline-block; + vertical-align: top; +} + +.hackathon-breakdown div img { + max-width: 250px; +} + @media screen and (max-width: 768px) { .content-block { diff --git a/app/dashboard/admin.py b/app/dashboard/admin.py index 0a23bcca48c..e14cc2f1bb1 100644 --- a/app/dashboard/admin.py +++ b/app/dashboard/admin.py @@ -272,7 +272,7 @@ class HackathonEventAdmin(admin.ModelAdmin): """The admin object for the HackathonEvent model.""" list_display = ['pk', 'img', 'name', 'start_date', 'end_date', 'explorer_link'] - readonly_fields = ['img', 'explorer_link'] + readonly_fields = ['img', 'explorer_link', 'stats'] def img(self, instance): """Returns a formatted HTML img node or 'n/a' if the HackathonEvent has no logo. diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 90efe415672..8f6171533ad 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -3376,6 +3376,21 @@ def __str__(self): """ return f'{self.name} - {self.start_date}' + @property + def bounties(self): + return Bounty.objects.filter(event=self).current() + + @property + def stats(self): + stats = { + 'range': f"{self.start_date.strftime('%m/%d/%Y')} to {self.end_date.strftime('%m/%d/%Y')}", + 'num_bounties': self.bounties.count(), + 'num_bounties_done': self.bounties.filter(idx_status='done').count(), + 'num_bounties_open': self.bounties.filter(idx_status='open').count(), + 'total_volume': sum(self.bounties.values_list('_val_usd_db', flat=True)), + } + return stats + def save(self, *args, **kwargs): """Define custom handling for saving HackathonEvent.""" from django.utils.text import slugify diff --git a/app/retail/templates/results.html b/app/retail/templates/results.html index a05f01ebef1..aa8fa7e1e4d 100644 --- a/app/retail/templates/results.html +++ b/app/retail/templates/results.html @@ -40,7 +40,7 @@

- ${{ universe_total_usd|floatformat:2|intcomma }} of {% blocktrans %} + ${{ universe_total_usd|floatformat:0|intcomma }} of {% blocktrans %} Gross Marketplace Value {% endblocktrans %} {% if keyword %}({{keyword}}){%endif%} @@ -133,6 +133,30 @@

{{ alumni_count }}

+
+
+

{{hackathons | length }} {% trans "Virtual Hackathons" %} worth ${{hackathon_total|floatformat:0|intcomma}}.

+ +
+ {% for hackathon in hackathons %} + {% firstof hackathon.0.logo_svg or hackathon.0.logo as logo %} +
+ {% if logo %} + + {%endif %} +

{{hackathon.0.name}}

+ {% if hackathon.1.num_bounties %} +

{{hackathon.1.num_bounties}} Bounties

+

${{hackathon.1.total_volume|floatformat:0|intcomma}} In Prizes

+ {% endif %} +

{{hackathon.1.range}}

+ View Prize Explorer +
+ {% endfor %} +
+
+
+

{% trans "Bounty Status Breakdown" %} {% if keyword %}({{keyword}}){%endif%}

diff --git a/app/retail/utils.py b/app/retail/utils.py index 1543a62bf03..b809a86bc27 100644 --- a/app/retail/utils.py +++ b/app/retail/utils.py @@ -414,7 +414,7 @@ def build_stat_results(keyword=None): Args: keyword (str): The keyword to build statistic results. """ - from dashboard.models import Bounty, Tip + from dashboard.models import Bounty, HackathonEvent, Tip context = { 'active': 'results', 'title': _('Results'), @@ -557,5 +557,8 @@ def build_stat_results(keyword=None): context['last_month_amount'] = round(sum(bh)/1000) context['last_month_amount_hourly'] = sum(bh) / 30 / 24 context['last_month_amount_hourly_business_hours'] = context['last_month_amount_hourly'] / 0.222 + context['hackathons'] = [(ele, ele.stats) for ele in HackathonEvent.objects.all()] + context['hackathon_total'] = [ele[1]['total_volume'] for ele in context['hackathons']] + return context