Skip to content

Commit c305d2a

Browse files
Deduplicate contributors configuration (#3399)
* merge script for review * updated config files * backwards compatibility in project scripts * more script adjustments * changed the key * final newlines * some fixes * new config processed in sequence * fix * fix * variable fix * restored original format * review feedback * json array newline fix * fix unknown mess
1 parent 5d7e015 commit c305d2a

8 files changed

Lines changed: 4330 additions & 4557 deletions

File tree

src/config/2019.json

Lines changed: 0 additions & 1034 deletions
Large diffs are not rendered by default.

src/config/2020.json

Lines changed: 0 additions & 1258 deletions
Large diffs are not rendered by default.

src/config/2021.json

Lines changed: 0 additions & 1157 deletions
Large diffs are not rendered by default.

src/config/2022.json

Lines changed: 0 additions & 1104 deletions
Large diffs are not rendered by default.

src/config/contributors.json

Lines changed: 4294 additions & 0 deletions
Large diffs are not rendered by default.

src/server/config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
config_json = {}
2121
timestamps_json = {}
22+
contributors = {}
2223

2324

2425
def get_config(year):
@@ -72,6 +73,7 @@ def update_config():
7273
global SUPPORTED_LANGUAGES
7374
global config_json
7475
global timestamps_json
76+
global contributors
7577

7678
config_files = []
7779

@@ -81,6 +83,10 @@ def update_config():
8183
config_filename = "config/%s" % file
8284
with open(config_filename, "r") as config_file:
8385
timestamps_json = json.load(config_file)
86+
elif file == "contributors.json":
87+
config_filename = "config/%s" % file
88+
with open(config_filename, "r") as config_file:
89+
contributors = json.load(config_file)
8490
elif ".json" in file:
8591
config_files.append(file[0:4])
8692

@@ -95,6 +101,14 @@ def update_config():
95101
SUPPORTED_LANGUAGES.update({year: get_languages(json_config)})
96102
SUPPORTED_CHAPTERS.update({year: set(get_chapters(json_config))})
97103

104+
# Add the contributors details that contributed to this year
105+
# for ease of look up later
106+
json_config["contributors"] = {}
107+
for contributor_id, contributor in contributors.items():
108+
if (year in contributor["teams"]):
109+
json_config["contributors"][contributor_id] = {**contributor}
110+
json_config["contributors"][contributor_id]["teams"] = contributor["teams"][year]
111+
98112
for contributor_id, contributor in json_config["contributors"].items():
99113
if "avatar_url" not in contributor:
100114
contributor["avatar_url"] = (

src/tools/generate/get_contributors_diff.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Show the contributors should be added in `config/year.json` file and which should remove based on their contributions in a perticular team
2+
* Show the contributors should be added in `config/contributors.json` file and which should remove based on their contributions in a perticular team
33
*
44
* @param {object} configs all config file generate with get_yearly_configs().
55
* @param {object} chapter_contributors parsed contributors for each year (author, analyst, reviewer, editor)[Must be a Set (finding is more efficient)]
@@ -27,7 +27,7 @@ const get_contributors_difference = async (configs, chapter_contributors) => {
2727
const config_contributors = configs[year].contributors;
2828
const year_chapter_contributors = chapter_contributors[year];
2929

30-
// Generates contributors who are in config/year.json file but not contributed for a team
30+
// Generates contributors who are in config/contributors.json file but not contributed for a team
3131
for (let contributor in config_contributors) {
3232
const contributor_teams = config_contributors[contributor].teams;
3333
if (contributor_teams.includes("analysts")) {
@@ -55,7 +55,7 @@ const get_contributors_difference = async (configs, chapter_contributors) => {
5555
}
5656
}
5757

58-
// Generates contributes who contributed in team but not in config/year.json file
58+
// Generates contributes who contributed in team but not in config/contributors.json file
5959
const year_chapter_authors = year_chapter_contributors.authors;
6060
const year_chapter_reviewers = year_chapter_contributors.reviewers;
6161
const year_chapter_analysts = year_chapter_contributors.analysts;
@@ -94,7 +94,7 @@ const get_contributors_difference = async (configs, chapter_contributors) => {
9494

9595
if (not_contributed_analysts.size > 0 || not_contributed_authors.size > 0 || not_contributed_reviewers.size > 0 || contributed_analysts.size > 0 || contributed_authors.size > 0 || contributed_reviewers.size > 0 || contributed_editors.size > 0) {
9696
console.log("\n****************************************************");
97-
console.log(`Contributor Discrepancies in config/${year}.json`);
97+
console.log(`Contributor Discrepancies in config/contributors.json for ${year}`);
9898
if (not_contributed_authors.size > 0 || contributed_authors.size > 0) {
9999
console.log("\tAuthors");
100100
if (not_contributed_authors.size > 0) {

src/tools/generate/shared.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ const find_config_files = async () => {
7979
return await recursive('config', [filter]);
8080
};
8181

82+
function get_yearly_contributors(year) {
83+
const contributorsData = JSON.parse(fs.readFileSync('config/contributors.json', 'utf8'));
84+
const yearlyContributors = {};
85+
86+
for (const contributorKey in contributorsData) {
87+
const yearContributions = contributorsData[contributorKey].teams[year];
88+
if (typeof yearContributions == "object") {
89+
yearlyContributors[contributorKey] = { ...contributorsData[contributorKey] }
90+
yearlyContributors[contributorKey].teams = yearContributions;
91+
}
92+
}
93+
94+
return yearlyContributors;
95+
}
96+
8297
const get_yearly_configs = async () => {
8398

8499
let configs = {};
@@ -90,6 +105,9 @@ const get_yearly_configs = async () => {
90105
const [path,year] = config_file.match(re);
91106

92107
configs[year] = JSON.parse(await fs.readFile(`config/${year}.json`, 'utf8'));
108+
109+
configs[year]["contributors"] = get_yearly_contributors(year);
110+
93111
}
94112
return configs;
95113
};

0 commit comments

Comments
 (0)