Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
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
209 changes: 209 additions & 0 deletions website/templates/projects/repo_detail.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "base.html" %}
{% load humanize %}
{% load static %}
{% load custom_filters %}
{% block title %}
{{ repo.name }} - Repo Details
{% endblock title %}
Expand Down Expand Up @@ -405,6 +406,119 @@ <h3 class="text-lg font-semibold text-gray-900">Commits</h3>
</div>
</div>
</section>
<!-- Statistics Charts -->
<section class="bg-white py-6 px-4 rounded-lg shadow-lg">
<h2 class="text-pink-500 font-bold text-lg">{{ repo.contributor_count|intcomma }} Contributions in the Last 30 Days</h2>
<div class="grid grid-cols-3 gap-2 mt-4">
<div class="p-4 border rounded-lg">
<span class="text-blue-500 text-sm flex w-full items-center justify-start">
<p class="mr-2" id="open-closed-issue-ratio"></p>
<p>Opened/Closed Issue Ratio</p>
</span>
<span class="text-xs flex justify-between items-center mt-3">
<p class="text-gray-400">{{ issue_ratio_change|floatformat:2 }} ({{ issue_ratio_percentage_change|floatformat:2 }}%)</p>
<p class="{% if issue_ratio_change >= 0 %}text-green-500{% else %}text-red-500{% endif %} flex items-center">
{% if issue_ratio_change >= 0 %}
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V17a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z" clip-rule="evenodd" />
</svg>
{% else %}
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V3a1 1 0 012 0v11.586l4.293-4.293a1 1 0 011.414 0z" clip-rule="evenodd" />
</svg>
{% endif %}
past month
</p>
</span>
</div>
<div class="p-4 border rounded-lg">
<span class="text-purple-500 text-sm flex w-full items-center justify-start">
<p class="mr-2">{{ repo.open_pull_requests|intcomma }}</p>
<p>Pull Requests Opened</p>
</span>
<span class="text-xs flex justify-between items-center mt-3">
<p class="text-gray-400">{{ pr_change|intcomma }} ({{ pr_percentage_change|floatformat:2 }}%)</p>
<p class="{% if pr_change >= 0 %}text-green-500{% else %}text-red-500{% endif %} flex items-center">
{% if pr_change >= 0 %}
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V17a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z" clip-rule="evenodd" />
</svg>
{% else %}
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V3a1 1 0 012 0v11.586l4.293-4.293a1 1 0 011.414 0z" clip-rule="evenodd" />
</svg>
{% endif %}
past month
</p>
</span>
</div>
<div class="p-4 border rounded-lg">
<span class="text-blue-500 text-sm flex w-full items-center justify-start">
<p class="mr-2">{{ repo.commit_count|intcomma }}</p>
<p>Commits</p>
</span>
<span class="text-xs flex justify-between items-center mt-3">
<p class="text-gray-400">{{ commit_change|intcomma }} ({{ commit_percentage_change|floatformat:2 }}%)</p>
<p class="{% if commit_change >= 0 %}text-green-500{% else %}text-red-500{% endif %} flex items-center">
{% if commit_change >= 0 %}
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V17a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z" clip-rule="evenodd" />
</svg>
{% else %}
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M16.707 10.293a1 1 0 010 1.414l-6 6a1 1 0 01-1.414 0l-6-6a1 1 0 111.414-1.414L9 14.586V3a1 1 0 012 0v11.586l4.293-4.293a1 1 0 011.414 0z" clip-rule="evenodd" />
</svg>
{% endif %}
past month
</p>
</span>
</div>
</div>
<div class="grid grid-cols-3 gap-4 mt-6">
<div class="p-4 border rounded-lg">
<div class="flex items-center justify-start">
<span class="p-2 rounded-full mr-2">
<svg class="w-5 h-5 text-blue-500"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</span>
<p class="text-blue-500">Issues</p>
</div>
<canvas id="issuesChart"></canvas>
</div>
<div class="p-4 border rounded-lg">
<div class="flex items-center justify-start">
<span class="p-2 rounded-full">
<svg class="w-5 h-5 text-purple-500"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" />
</svg>
</span>
<p class="text-purple-500">Pull Requests</p>
</div>
<canvas id="prChart"></canvas>
</div>
<div class="p-4 border rounded-lg">
<div class="flex items-center justify-start">
<span class="p-2 rounded-full">
<svg class="w-5 h-5 text-orange-500"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</span>
<p class="text-orange-500">Pushes & Commits</p>
</div>
<canvas id="commitsChart"></canvas>
</div>
</div>
</section>
<!-- Community Section -->
<section class="bg-white rounded-xl shadow-lg border border-gray-200 overflow-hidden">
<div class="p-6">
Expand Down Expand Up @@ -1258,5 +1372,100 @@ <h3 class="text-lg font-semibold text-gray-900">Issues with Bounties</h3>
}
});
</script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const open_issues = {{repo.open_issues}};
const closed_issues = {{repo.closed_issues}};

const open_closed_issue_ratio = (open_issues / closed_issues).toFixed(2);
const open_closed_issue_ratio_elem = document.getElementById("open-closed-issue-ratio");
open_closed_issue_ratio_elem.innerHTML = open_closed_issue_ratio;
</script>
<script>
const issuesCtx = document.getElementById('issuesChart').getContext('2d');

new Chart(issuesCtx, {
type: 'bar',
data: {
labels: {{ issues_labels|to_json }},
datasets: [{
label: 'Opened',
data: {{ issues_opened|to_json }},
backgroundColor: 'rgba(59, 130, 246, 0.5)',
borderColor: 'rgba(59, 130, 246, 1)',
borderWidth: 1
}, {
label: 'Closed',
data: {{ issues_closed|to_json }},
backgroundColor: 'rgba(29, 78, 216, 0.5)',
borderColor: 'rgba(29, 78, 216, 1)',
borderWidth: 1
}]
},
options: {
scales: {
x: {
display: false
}
}
},
});

const prCtx = document.getElementById('prChart').getContext('2d');
new Chart(prCtx, {
type: 'bar',
data: {
labels: {{ pr_labels|to_json }},
datasets: [{
label: 'Opened',
data: {{ pr_opened_data|to_json }},
backgroundColor: 'rgba(192, 38, 211, 0.5)',
borderColor: 'rgba(192, 38, 211, 1)',
borderWidth: 1
}, {
label: 'Closed',
data: {{ pr_closed_data|to_json }},
backgroundColor: 'rgba(109, 40, 217, 0.5)',
borderColor: 'rgba(109, 40, 217, 1)',
borderWidth: 1
}]
},
options: {
scales: {
x: {
display: false
}
}
},
});

const commitsCtx = document.getElementById('commitsChart').getContext('2d');
new Chart(commitsCtx, {
type: 'bar',
data: {
labels: {{ commits_labels|to_json }},
datasets: [{
label: 'Pushes',
data: {{ pushes_data }},
backgroundColor: 'rgba(234, 88, 12, 0.5)',
borderColor: 'rgba(234, 88, 12, 1)',
borderWidth: 1
}, {
label: 'Commits',
data: {{ commits_data|to_json }},
backgroundColor: 'rgba(194, 65, 12, 0.5)',
borderColor: 'rgba(194, 65, 12, 1)',
borderWidth: 1
}]
},
options: {
scales: {
x: {
display: false
}
}
},
});
</script>
<script src="{% static 'js/repo_detail.js' %}"></script>
{% endblock after_js %}
9 changes: 9 additions & 0 deletions website/templatetags/custom_filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import json

from django import template
from django.core.serializers.json import DjangoJSONEncoder
from django.utils.safestring import mark_safe

register = template.Library()

Expand All @@ -12,3 +16,8 @@ def get_item(dictionary, key):
@register.filter
def before_dot(value):
return str(value).split(".")[0]

@register.filter(name="to_json", is_safe=True)
def to_json(value):
"""Convert Python object to JSON string"""
return mark_safe(json.dumps(value, cls=DjangoJSONEncoder))
Loading
Loading