Bladeren bron

Displaying top stargazers

David Leonard 10 jaren geleden
bovenliggende
commit
182db38e59

+ 1 - 1
hackathon_starter/hackathon/scripts/github.py

@@ -126,7 +126,7 @@ def filterStarGazerCount(data):
 	maxStars= []
 	for i in range(1, 10):
 		maxStarGazers = max(data, key=lambda x:x['stargazers_count'])
-		maxCommits.append(maxStarGazers)
+		maxStars.append(maxStarGazers)
 		index = data.index(maxStarGazers)
 		data.pop(index)
 	return maxStars

+ 44 - 20
hackathon_starter/hackathon/templates/hackathon/github.html

@@ -37,28 +37,52 @@
         </div>
     </div>
 
-    <h2> Top Contributed Repositories </h2>
-    <div class="col-lg-3">
-        <div class="table-responsive">
-            <table class="table table-bordered table-hover table-striped tablesorter">
-                <thead>
-                <tr>
-                <th class="header"> Repository <i class="icon-sort"></i></th>
-                <th class="header"> Total <i class="icon-sort"></i></th>
-                </tr>
-            </thead>
-            <tbody>
+        <div class="col-xs-6">
+            <h2> Top Contributed Repositories </h2>
+            <div class="table-responsive">
+                <table class="table table-bordered table-hover table-striped tablesorter">
+                    <thead>
+                    <tr>
+                    <th class="header"> Repository <i class="icon-sort"></i></th>
+                    <th class="header"> Total <i class="icon-sort"></i></th>
+                    </tr>
+                </thead>
+                <tbody>
 
-            {% for key in data.filteredData %}
-                <tr>
-                    <td>{{ key.repo_name }}</td>
-                    <td>{{ key.total }}</td>
-                </tr>
-            {% endfor %}
+                {% for key in data.filteredData %}
+                    <tr>
+                        <td>{{ key.repo_name }}</td>
+                        <td>{{ key.total }}</td>
+                    </tr>
+                {% endfor %}
 
-            </tbody>
-            </table>
+                </tbody>
+                </table>
+            </div>
         </div>
-    </div>
+        <div class="col-xs-6">
+            <h2> Top Starred Repositories </h2>
+            <div class="table-responsive">
+                <table class="table table-bordered table-hover table-striped tablesorter">
+                    <thead>
+                    <tr>
+                    <th class="header"> Repository <i class="icon-sort"></i></th>
+                    <th class="header"> Count <i class="icon-sort"></i></th>
+                    </tr>
+                </thead>
+                <tbody>
+
+                {% for key in data.filteredStargazers %}
+                    <tr>
+                        <td>{{ key.name }}</td>
+                        <td>{{ key.stargazers_count }}</td>
+                    </tr>
+                {% endfor %}
+
+                </tbody>
+                </table>
+            </div>
+        </div>
+
 </body>
 </html>

+ 5 - 1
hackathon_starter/hackathon/views.py

@@ -126,11 +126,15 @@ def github(request):
     list = getTopContributedRepositories(repositories)
     # Get a list of the top 10 most committed repositories
     filtered = filterCommits(list)
+    # Get list of all stargazer counts for all repositories
     stargazers = getStarGazerCount()
-    print stargazers
+    # Return list of top 10 stargazed repositories
+    filteredStargazers = filterStarGazerCount(stargazers)
+    
     # Store data into a dictionary for rendering
     allData['userData'] = userData
     allData['filteredData'] = filtered
+    allData['filteredStargazers'] = filteredStargazers
 
     return render(request, 'hackathon/github.html', { 'data': allData })