Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/get_repo_metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
gh release view --repo DesignLiquido/delegua --json name,tagName,publishedAt,url > lastReleaseData.json

echo "### Contributors Count ###"
gh api repos/DesignLiquido/delegua/contributors --paginate | jq length > contriburosCount.json
gh api repos/DesignLiquido/delegua/contributors --paginate | jq length > contributorsCount.json

echo "### Issues Count - OPEN ###"
gh api 'search/issues?q=repo:DesignLiquido/delegua+is:issue+is:open' --jq '.total_count' > openIssuesCount.json
Expand Down Expand Up @@ -68,11 +68,11 @@ jobs:
name: lastReleaseData
path: lastReleaseData.json

- name: Upload contriburosCount.json
- name: Upload contributorsCount.json
uses: actions/upload-artifact@v4
with:
name: contriburosCount
path: contriburosCount.json
name: contributorsCount
path: contributorsCount.json

- name: Upload openIssuesCount.json
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions files/closedIssuesCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
212
1 change: 1 addition & 0 deletions files/closedPRsCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
552
1 change: 1 addition & 0 deletions files/communityStandards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"health_percentage":75,"description":"Linguagem de programação 100% em português baseada em TypeScript, independente de sistema operacional e dispositivo, e suporte a múltiplos dialetos.","documentation":"https://designliquido.github.io/delegua/","files":{"code_of_conduct":null,"code_of_conduct_file":null,"contributing":{"url":"https://api.github.com/repos/DesignLiquido/delegua/contents/CONTRIBUTING.md","html_url":"https://github.com/DesignLiquido/delegua/blob/principal/CONTRIBUTING.md"},"issue_template":null,"pull_request_template":null,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz","html_url":"https://github.com/DesignLiquido/delegua/blob/principal/LICENSE"},"readme":{"url":"https://api.github.com/repos/DesignLiquido/delegua/contents/README.md","html_url":"https://github.com/DesignLiquido/delegua/blob/principal/README.md"}},"updated_at":"2025-07-16T17:00:12Z","content_reports_enabled":true}
1 change: 1 addition & 0 deletions files/contributorsCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
1 change: 1 addition & 0 deletions files/forkCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"forkCount":26}
1 change: 1 addition & 0 deletions files/lastReleaseData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"0.48.2","publishedAt":"2025-08-02T20:40:49Z","tagName":"0.48.2","url":"https://github.com/DesignLiquido/delegua/releases/tag/0.48.2"}
1 change: 1 addition & 0 deletions files/openIssuesCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8
1 change: 1 addition & 0 deletions files/openPRsCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
1 change: 1 addition & 0 deletions files/security.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"isSecurityPolicyEnabled":true}
1 change: 1 addition & 0 deletions files/stargazerCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"stargazerCount":332}
1 change: 1 addition & 0 deletions files/watchersCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"watchers":{"totalCount":6}}
2 changes: 2 additions & 0 deletions repo_health_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stars_count,watchers_count,fork_count,last_release_name,last_release_date,contributors_count,open_issues_count,closed_issues_count,open_prs_count,closed_prs_count,community_stardards_description,community_stardards_readme,community_stardards_code_of_conduct,community_stardards_contributing,community_stardards_license,community_stardards_security_policy,community_stardards_issues_templates,community_stardards_pr_template,community_stardards_content_reports_enabled
332,6,26,0.48.2,2025-08-02T20:40:49Z,16,8,212,1,552,True,True,False,True,True,True,False,False,True
89 changes: 89 additions & 0 deletions scripts/generate_csv.py
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a suggestion to improve the maintainability and readability of this script: consider refactoring the repeated code blocks for loading JSON files and building the data dictionary into functions. This would help avoid repetition, make the code easier to update, and simplify testing in the future. One idea of how it could look like:

import json
import csv

STAR_COUNT_FILE = 'stargazerCount.json'
WATCHERS_COUNT_FILE = 'watchersCount.json'
FORK_COUNT_FILE = 'forkCount.json'
LAST_RELEASE_FILE = 'lastReleaseData.json'
CONTRIBUTORS_COUNT_FILE = 'contributorsCount.json'
OPEN_ISSUES_COUNT_FILE = 'openIssuesCount.json'
CLOSED_ISSUES_COUNT_FILE = 'closedIssuesCount.json'
OPEN_PRS_COUNT_FILE = 'openPRsCount.json'
CLOSED_PRS_COUNT_FILE = 'closedPRsCount.json'
COMMUNITY_STANDARDS_FILE = 'communityStandards.json'
SECURITY_FILE = 'security.json'

OUTPUT_FILE = "repo_health_data.csv"

def build_repo_data():
    pass

def write_csv(data, filename=OUTPUT_FILE):
    pass

def load_json(filepath):
    with open(filepath) as f:
        return json.load(f)

if __name__ == "__main__":
    repo_data_dict = build_repo_data()
    write_csv(repo_data_dict)
    print(repo_data_dict)

You can also create methods to get the nested attributes in a dict, to evaluate if the key is inside the dict... so then you can reuse them and make things easier to read and test.

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import json, csv

# --- OPEN JSON FILES --- #
# Star count
with open('./files/stargazerCount.json') as star_count_json:
star_count_data = json.load(star_count_json)
# print('Star count: ', star_count_data,'\n')

# Watchers count
with open('./files/watchersCount.json') as watchers_count_json:
watchers_count_data = json.load(watchers_count_json)
# print('Watchers count: ', watchers_count_data,'\n')

# Fork count
with open('./files/forkCount.json') as fork_count_json:
fork_count_data = json.load(fork_count_json)
# print('Fork count: ', fork_count_data)

# Last Release
with open('./files/lastReleaseData.json') as last_release_json:
last_release_data = json.load(last_release_json)
# print('Last release: ', last_release_data)
''
# Contributors Count
with open('./files/contributorsCount.json') as contributors_count_json:
contributors_count_data = json.load(contributors_count_json)
# print('Conbributors count: ', contributors_count_data)

# Open Issues
with open ('./files/openIssuesCount.json') as open_issues_count_json:
open_issues_count_data = json.load(open_issues_count_json)
# print('Open ISSUES: ', open_issues_count_data)

# Closed Issues
with open('./files/closedIssuesCount.json') as closed_issues_count_json:
closed_issues_count_data = json.load(closed_issues_count_json)
# print('Closed ISSUES: ', closed_issues_count_data)

# Open PRs Count
with open('./files/openPRsCount.json') as open_prs_count_json:
open_prs_count_data = json.load(open_prs_count_json)
# print('Open PRs: ', open_prs_count_data)

# Closed PRs Count
with open('./files/closedPRsCount.json') as closed_prs_count_json:
closed_prs_count_data = json.load(closed_prs_count_json)
# print('Closed PRs: ', closed_prs_count_data)

# Community Standards
with open('./files/communityStandards.json') as community_standards_json:
community_standards_data = json.load(community_standards_json)
# print('Community Standards: ', community_standards_data)

# Security Data
with open('./files/security.json', 'r') as security_json:
secutiry_data = json.load(security_json)
Comment thread
maitecr marked this conversation as resolved.
Outdated
# print('Secutiry enabled: ', secutiry_data)


print('TESTS: generating dicts')

repo_data_dict = {
Comment thread
maitecr marked this conversation as resolved.
Outdated
'stars_count': star_count_data['stargazerCount'],
'watchers_count': watchers_count_data['watchers']['totalCount'],
'fork_count': fork_count_data['forkCount'],
'last_release_name': last_release_data['name'],
'last_release_date': last_release_data['publishedAt'],
'contributors_count': contributors_count_data,
'open_issues_count': open_issues_count_data,
'closed_issues_count': closed_issues_count_data,
'open_prs_count': open_prs_count_data,
'closed_prs_count': closed_prs_count_data,
'community_stardards_description': True if community_standards_data.get('description') else False,
Comment thread
maitecr marked this conversation as resolved.
Outdated
'community_stardards_readme': True if community_standards_data.get('files', {}).get('readme') is not None else False ,
'community_stardards_code_of_conduct': True if community_standards_data.get('files', {}).get('code_of_conduct') is not None else False,
'community_stardards_contributing': True if community_standards_data.get('files', {}).get('contributing', {}).get('url') is not None else False,
'community_stardards_license': True if community_standards_data.get('files', {}).get('license', {}.get('name')) is not None else False,
Comment thread
maitecr marked this conversation as resolved.
Outdated
'community_stardards_security_policy': secutiry_data['isSecurityPolicyEnabled'],
'community_stardards_issues_templates': True if community_standards_data.get('files', {}).get('issue_template') is not None else False,
'community_stardards_pr_template': True if community_standards_data.get('files', {}).get('pull_request_template') is not None else False,
'community_stardards_content_reports_enabled': community_standards_data.get('content_reports_enabled')
Comment thread
maitecr marked this conversation as resolved.
Outdated
}

with open("repo_health_data.csv", "w", newline="", encoding="utf-8") as repo_health_data:
writer = csv.DictWriter(repo_health_data, fieldnames=repo_data_dict.keys())
writer.writeheader()
writer.writerow(repo_data_dict)

print(repo_data_dict)