Skip to content

Commit 764b9a3

Browse files
committed
Add option to hide repository statistics section
- Introduce `show_repo_stats` context variable to control visibility of repo stats - Provide default setting of `False` to hide statistics section - Create empty activity data structure when stats are disabled to prevent template errors
1 parent 00d3b4f commit 764b9a3

File tree

2 files changed

+137
-111
lines changed

2 files changed

+137
-111
lines changed

website/templates/projects/repo_detail.html

+111-109
Original file line numberDiff line numberDiff line change
@@ -407,122 +407,124 @@ <h3 class="text-lg font-semibold text-gray-900">Commits</h3>
407407
</div>
408408
</section>
409409
<!-- Statistics Charts -->
410-
<section class="bg-white py-6 px-4 rounded-lg shadow-lg">
411-
<h2 class="text-pink-500 font-bold text-lg">
412-
{{ repo.contributor_count|intcomma }} Contributions in the Last 30 Days
413-
</h2>
414-
<div class="grid grid-cols-3 gap-2 mt-4">
415-
<div class="p-4 border rounded-lg">
416-
<span class="text-blue-500 text-sm flex w-full items-center justify-start">
417-
<p class="mr-2" id="open-closed-issue-ratio"></p>
418-
<p>Opened/Closed Issue Ratio</p>
419-
</span>
420-
<span class="text-xs flex justify-between items-center mt-3">
421-
<p class="text-gray-400">
422-
{{ issue_ratio_change|floatformat:2 }} ({{ issue_ratio_percentage_change|floatformat:2 }}%)
423-
</p>
424-
<p class="{% if issue_ratio_change >= 0 %}text-green-500{% else %}text-red-500{% endif %} flex items-center">
425-
{% if issue_ratio_change >= 0 %}
426-
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
427-
<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" />
428-
</svg>
429-
{% else %}
430-
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
431-
<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" />
432-
</svg>
433-
{% endif %}
434-
past month
435-
</p>
436-
</span>
437-
</div>
438-
<div class="p-4 border rounded-lg">
439-
<span class="text-purple-500 text-sm flex w-full items-center justify-start">
440-
<p class="mr-2">{{ repo.open_pull_requests|intcomma }}</p>
441-
<p>Pull Requests Opened</p>
442-
</span>
443-
<span class="text-xs flex justify-between items-center mt-3">
444-
<p class="text-gray-400">{{ pr_change|intcomma }} ({{ pr_percentage_change|floatformat:2 }}%)</p>
445-
<p class="{% if pr_change >= 0 %}text-green-500{% else %}text-red-500{% endif %} flex items-center">
446-
{% if pr_change >= 0 %}
447-
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
448-
<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" />
449-
</svg>
450-
{% else %}
451-
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
452-
<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" />
453-
</svg>
454-
{% endif %}
455-
past month
456-
</p>
457-
</span>
458-
</div>
459-
<div class="p-4 border rounded-lg">
460-
<span class="text-blue-500 text-sm flex w-full items-center justify-start">
461-
<p class="mr-2">{{ repo.commit_count|intcomma }}</p>
462-
<p>Commits</p>
463-
</span>
464-
<span class="text-xs flex justify-between items-center mt-3">
465-
<p class="text-gray-400">{{ commit_change|intcomma }} ({{ commit_percentage_change|floatformat:2 }}%)</p>
466-
<p class="{% if commit_change >= 0 %}text-green-500{% else %}text-red-500{% endif %} flex items-center">
467-
{% if commit_change >= 0 %}
468-
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
469-
<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" />
470-
</svg>
471-
{% else %}
472-
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
473-
<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" />
474-
</svg>
475-
{% endif %}
476-
past month
477-
</p>
478-
</span>
479-
</div>
480-
</div>
481-
<div class="grid grid-cols-3 gap-4 mt-6">
482-
<div class="p-4 border rounded-lg">
483-
<div class="flex items-center justify-start">
484-
<span class="p-2 rounded-full mr-2">
485-
<svg class="w-5 h-5 text-blue-500"
486-
fill="none"
487-
stroke="currentColor"
488-
viewBox="0 0 24 24">
489-
<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" />
490-
</svg>
410+
{% if show_repo_stats %}
411+
<section class="bg-white py-6 px-4 rounded-lg shadow-lg">
412+
<h2 class="text-pink-500 font-bold text-lg">
413+
{{ repo.contributor_count|intcomma }} Contributions in the Last 30 Days
414+
</h2>
415+
<div class="grid grid-cols-3 gap-2 mt-4">
416+
<div class="p-4 border rounded-lg">
417+
<span class="text-blue-500 text-sm flex w-full items-center justify-start">
418+
<p class="mr-2" id="open-closed-issue-ratio"></p>
419+
<p>Opened/Closed Issue Ratio</p>
420+
</span>
421+
<span class="text-xs flex justify-between items-center mt-3">
422+
<p class="text-gray-400">
423+
{{ issue_ratio_change|floatformat:2 }} ({{ issue_ratio_percentage_change|floatformat:2 }}%)
424+
</p>
425+
<p class="{% if issue_ratio_change >= 0 %}text-green-500{% else %}text-red-500{% endif %} flex items-center">
426+
{% if issue_ratio_change >= 0 %}
427+
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
428+
<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" />
429+
</svg>
430+
{% else %}
431+
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
432+
<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" />
433+
</svg>
434+
{% endif %}
435+
past month
436+
</p>
491437
</span>
492-
<p class="text-blue-500">Issues</p>
493438
</div>
494-
<canvas id="issuesChart"></canvas>
495-
</div>
496-
<div class="p-4 border rounded-lg">
497-
<div class="flex items-center justify-start">
498-
<span class="p-2 rounded-full">
499-
<svg class="w-5 h-5 text-purple-500"
500-
fill="none"
501-
stroke="currentColor"
502-
viewBox="0 0 24 24">
503-
<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" />
504-
</svg>
439+
<div class="p-4 border rounded-lg">
440+
<span class="text-purple-500 text-sm flex w-full items-center justify-start">
441+
<p class="mr-2">{{ repo.open_pull_requests|intcomma }}</p>
442+
<p>Pull Requests Opened</p>
443+
</span>
444+
<span class="text-xs flex justify-between items-center mt-3">
445+
<p class="text-gray-400">{{ pr_change|intcomma }} ({{ pr_percentage_change|floatformat:2 }}%)</p>
446+
<p class="{% if pr_change >= 0 %}text-green-500{% else %}text-red-500{% endif %} flex items-center">
447+
{% if pr_change >= 0 %}
448+
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
449+
<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" />
450+
</svg>
451+
{% else %}
452+
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
453+
<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" />
454+
</svg>
455+
{% endif %}
456+
past month
457+
</p>
505458
</span>
506-
<p class="text-purple-500">Pull Requests</p>
507459
</div>
508-
<canvas id="prChart"></canvas>
509-
</div>
510-
<div class="p-4 border rounded-lg">
511-
<div class="flex items-center justify-start">
512-
<span class="p-2 rounded-full">
513-
<svg class="w-5 h-5 text-orange-500"
514-
fill="none"
515-
stroke="currentColor"
516-
viewBox="0 0 24 24">
517-
<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" />
518-
</svg>
460+
<div class="p-4 border rounded-lg">
461+
<span class="text-blue-500 text-sm flex w-full items-center justify-start">
462+
<p class="mr-2">{{ repo.commit_count|intcomma }}</p>
463+
<p>Commits</p>
464+
</span>
465+
<span class="text-xs flex justify-between items-center mt-3">
466+
<p class="text-gray-400">{{ commit_change|intcomma }} ({{ commit_percentage_change|floatformat:2 }}%)</p>
467+
<p class="{% if commit_change >= 0 %}text-green-500{% else %}text-red-500{% endif %} flex items-center">
468+
{% if commit_change >= 0 %}
469+
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
470+
<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" />
471+
</svg>
472+
{% else %}
473+
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20">
474+
<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" />
475+
</svg>
476+
{% endif %}
477+
past month
478+
</p>
519479
</span>
520-
<p class="text-orange-500">Pushes & Commits</p>
521480
</div>
522-
<canvas id="commitsChart"></canvas>
523481
</div>
524-
</div>
525-
</section>
482+
<div class="grid grid-cols-3 gap-4 mt-6">
483+
<div class="p-4 border rounded-lg">
484+
<div class="flex items-center justify-start">
485+
<span class="p-2 rounded-full mr-2">
486+
<svg class="w-5 h-5 text-blue-500"
487+
fill="none"
488+
stroke="currentColor"
489+
viewBox="0 0 24 24">
490+
<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" />
491+
</svg>
492+
</span>
493+
<p class="text-blue-500">Issues</p>
494+
</div>
495+
<canvas id="issuesChart"></canvas>
496+
</div>
497+
<div class="p-4 border rounded-lg">
498+
<div class="flex items-center justify-start">
499+
<span class="p-2 rounded-full">
500+
<svg class="w-5 h-5 text-purple-500"
501+
fill="none"
502+
stroke="currentColor"
503+
viewBox="0 0 24 24">
504+
<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" />
505+
</svg>
506+
</span>
507+
<p class="text-purple-500">Pull Requests</p>
508+
</div>
509+
<canvas id="prChart"></canvas>
510+
</div>
511+
<div class="p-4 border rounded-lg">
512+
<div class="flex items-center justify-start">
513+
<span class="p-2 rounded-full">
514+
<svg class="w-5 h-5 text-orange-500"
515+
fill="none"
516+
stroke="currentColor"
517+
viewBox="0 0 24 24">
518+
<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" />
519+
</svg>
520+
</span>
521+
<p class="text-orange-500">Pushes & Commits</p>
522+
</div>
523+
<canvas id="commitsChart"></canvas>
524+
</div>
525+
</div>
526+
</section>
527+
{% endif %}
526528
<!-- Community Section -->
527529
<section class="bg-white rounded-xl shadow-lg border border-gray-200 overflow-hidden">
528530
<div class="p-6">

website/views/project.py

+26-2
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,32 @@ def get_context_data(self, **kwargs):
950950
owner_repo = repo.repo_url.rstrip("/").split("github.com/")[-1]
951951
owner, repo_name = owner_repo.split("/")
952952

953-
# Get activity data
954-
activity_data = self.fetch_activity_data(owner, repo_name)
953+
# Add show_repo_stats parameter set to False to hide stats section
954+
context["show_repo_stats"] = False
955+
956+
# Get activity data only if we're showing repo stats
957+
activity_data = None
958+
if context["show_repo_stats"]:
959+
activity_data = self.fetch_activity_data(owner, repo_name)
960+
else:
961+
# Create empty activity data structure to avoid template errors
962+
activity_data = {
963+
"issues_labels": [],
964+
"issues_opened": [],
965+
"issues_closed": [],
966+
"pr_labels": [],
967+
"pr_opened_data": [],
968+
"pr_closed_data": [],
969+
"commits_labels": [],
970+
"commits_data": [],
971+
"pushes_data": [],
972+
"issue_ratio_change": 0,
973+
"pr_change": 0,
974+
"commit_change": 0,
975+
"issue_ratio_percentage_change": 0,
976+
"pr_percentage_change": 0,
977+
"commit_percentage_change": 0,
978+
}
955979

956980
# Add breadcrumbs
957981
context["breadcrumbs"] = [

0 commit comments

Comments
 (0)