team page: Remove duplicate contribution counts.

It removes duplicate contribution count from zulip-server.

Fixes #7836.
This commit is contained in:
sinwar 2018-03-03 12:21:55 +00:00 committed by Tim Abbott
parent c3964dff6e
commit 6bed6ccdcf
2 changed files with 82 additions and 2 deletions

View File

@ -8,7 +8,7 @@ JSON data for the /team page contributors section.
from lib import sanity_check
sanity_check.check_venv(__file__)
from typing import Any, Dict, List, Optional, Union, Text
from typing import Any, Dict, List, Optional, Union, Text, cast
from mypy_extensions import TypedDict
import os
@ -27,6 +27,7 @@ from django.conf import settings
from zerver.lib.utils import split_by
FIXTURE_FILE = os.path.join(os.path.dirname(__file__), '../zerver/fixtures/authors.json')
duplicate_commits_file = os.path.join(os.path.dirname(__file__), '../zerver/fixtures/duplicate_commits.json')
parser = argparse.ArgumentParser()
parser.add_argument('--max-retries', type=int, default=3,
@ -50,7 +51,6 @@ def fetch_contributors(repo_link: str) -> Optional[List[Dict[str, Dict[str, Any]
r = requests.get(repo_link) # type: requests.Response
return r.json() if r.status_code == 200 else None
def write_to_disk(json_data: ContributorsJSON, out_file: str) -> None:
with open(out_file, 'w') as f:
try:
@ -97,6 +97,18 @@ def run_production() -> None:
contribs_list[username].update(contrib_data)
else:
contribs_list[username] = contrib_data
# remove duplicate contributions count
# find commits at the time of split and substract from zulip-server
with open(duplicate_commits_file, 'r') as f:
duplicate_commits = json.loads(f.read())
for committer in duplicate_commits:
if contribs_list[committer].get('server'):
total_commits = cast(int, contribs_list[committer]['server'])
duplicate_commits_count = duplicate_commits[committer]
original_commits = total_commits - duplicate_commits_count
contribs_list[committer]['server'] = original_commits
for repo in repos_done:
del repositories[repo]

View File

@ -0,0 +1,68 @@
{
"TomaszKolek": 2,
"zbenjamin": 91,
"robot-dreams": 5,
"lfaraone": 22,
"jhurwitz": 4,
"roed314": 2,
"florean": 2,
"sharmaeklavya2": 16,
"acrefoot": 4,
"sampritipanda": 2,
"rishig": 3,
"tukruic": 5,
"Bickio": 1,
"rwbarton": 4,
"Juanvulcano": 1,
"dariaphoebe": 1,
"lonerz": 3,
"HydraulicSheep": 3,
"starrvinc": 1,
"jajodiaraghav": 1,
"abhayKashyap03": 1,
"ImperialLlama": 1,
"540KJ": 6,
"showell": 13,
"umkhan": 2,
"anirudhjain75": 1,
"theairportexplorer": 3,
"lfranchi": 17,
"abhijeetkaur": 33,
"andersk": 3,
"wdaher": 16,
"andrewallen00": 2,
"jordangedney": 2,
"adnrs96": 20,
"ashishk1994": 1,
"maydhak": 1,
"enhdless": 1,
"neiljp": 14,
"reyha": 2,
"tommyip": 9,
"vabs22": 5,
"eeshangarg": 6,
"taranjeet": 1,
"roryk": 2,
"bungeye": 1,
"armooo": 4,
"fazerlicourice7": 5,
"jonjonsonjr": 1,
"joyhchen": 2,
"paxapy": 1,
"royabouhamad": 2,
"shane-kearns": 4,
"zacps": 1,
"AZtheAsian": 6,
"ParthMahawar": 1,
"timabbott": 500,
"YagoGG": 5,
"sahildua2305": 1,
"bmorg": 1,
"sinwar": 2,
"soudy": 1,
"aero31aero": 8,
"umairwaheed": 1,
"roberthoenig": 39,
"refeed": 9,
"dwrpayne": 1
}