Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Load current number of stars from GitHub

Roland Geider6c7056c01cce
diff --git a/wger/software/templates/features.html b/wger/software/templates/features.html
index aeecb5b0c..2366313f7 100644
--- a/wger/software/templates/features.html
+++ b/wger/software/templates/features.html
@@ -97,7 +97,7 @@
<p class="text-center">foods <br> for meal planing</p>
</div>
<div class="col-lg-3 col-sm-3 d-flex flex-column align-items-center">
- <h2 class="display-3 font-bebas-neue text-dark-blue mb-0">2000+</h2>
+ <h2 class="display-3 font-bebas-neue text-dark-blue mb-0">{{ nr_stars }}+</h2>
<p class="text-center">stars <br> on GitHub</p>
</div>
</section>
diff --git a/wger/software/views.py b/wger/software/views.py
index deb6f09df..299da8a4f 100644
--- a/wger/software/views.py
+++ b/wger/software/views.py
@@ -23,10 +23,14 @@ from django.contrib.auth.models import User
from django.shortcuts import render
from django.views.decorators.cache import cache_page
+# Third Party
+import requests
+
# wger
from wger.exercises.models import ExerciseBase
from wger.nutrition.models import Ingredient
+
logger = logging.getLogger(__name__)
@@ -36,11 +40,15 @@ def features(request):
Render the features page
"""
+ # Fetch number of stars from GitHub. The page is cached, so doing this is OK
+ result = requests.get('https://api.github.com/repos/wger-project/wger').json()
+
context = {
'allow_registration': settings.WGER_SETTINGS['ALLOW_REGISTRATION'],
'allow_guest_users': settings.WGER_SETTINGS['ALLOW_GUEST_USERS'],
'nr_users': User.objects.count(),
'nr_exercises': ExerciseBase.objects.count(),
- 'nr_ingredients': Ingredient.objects.count()
+ 'nr_ingredients': Ingredient.objects.count(),
+ 'nr_stars': result.get('stargazers_count', '2000')
}
return render(request, 'features.html', context)