From dc26e6b3901fcd47a092b051a35d5564bbb5e29a Mon Sep 17 00:00:00 2001 From: Sam Ginn Date: Wed, 25 Jan 2017 13:10:57 -0800 Subject: [PATCH] prefer sending definitions with cites --- community-server/server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/community-server/server.py b/community-server/server.py index fdb8990..7e56aef 100755 --- a/community-server/server.py +++ b/community-server/server.py @@ -251,7 +251,13 @@ def emit_top_builders(): (citations, citation_score) = compute_citations(subdir) if len(top_5_builders) < 5 or citation_score > top_5_builders[4][0]: - citations = sorted(citations, key=lambda c: c["cite"], reverse=True)[:5] + # If there are more than 5 citations with cites, only return those + citations_with_cites = [c for c in citations if c["cite"] > 0] + if len(citations_with_cites) >= 5: + citations = citations_with_cites + + # Sort them by scorem and return the top 5. + citations = sorted(citations, key=lambda c: c["cite"] + c["self"], reverse=True)[:5] struct = (uid, citation_score, citations) if len(top_5_builders) < 5: