changes github graph for the demo
This commit is contained in:
parent
d8fde4c527
commit
1267f6c1e7
3 changed files with 10 additions and 13 deletions
|
|
@ -51,7 +51,6 @@ def create_repository_datapoint(repo_name: str, nodesets: List[NodeSet]) -> Repo
|
||||||
name=repo_name,
|
name=repo_name,
|
||||||
has_issue=[],
|
has_issue=[],
|
||||||
has_commit=[],
|
has_commit=[],
|
||||||
contains=[],
|
|
||||||
belongs_to_set=nodesets,
|
belongs_to_set=nodesets,
|
||||||
)
|
)
|
||||||
logger.debug(f"Created Repository with ID: {repo_id} for {repo_name}")
|
logger.debug(f"Created Repository with ID: {repo_id} for {repo_name}")
|
||||||
|
|
@ -80,7 +79,6 @@ def create_commit_datapoint(
|
||||||
commit_url=commit_data.get("commit_url", ""),
|
commit_url=commit_data.get("commit_url", ""),
|
||||||
author_name=commit_data.get("login", ""),
|
author_name=commit_data.get("login", ""),
|
||||||
repo=commit_data.get("repo", ""),
|
repo=commit_data.get("repo", ""),
|
||||||
authored_by=user,
|
|
||||||
has_change=[],
|
has_change=[],
|
||||||
belongs_to_set=nodesets,
|
belongs_to_set=nodesets,
|
||||||
)
|
)
|
||||||
|
|
@ -89,7 +87,7 @@ def create_commit_datapoint(
|
||||||
|
|
||||||
|
|
||||||
def create_file_change_datapoint(
|
def create_file_change_datapoint(
|
||||||
fc_data: Dict[str, Any], file: File, nodesets: List[NodeSet]
|
fc_data: Dict[str, Any], user: GitHubUser, file: File, nodesets: List[NodeSet]
|
||||||
) -> FileChange:
|
) -> FileChange:
|
||||||
"""Creates a FileChange DataPoint with a consistent ID."""
|
"""Creates a FileChange DataPoint with a consistent ID."""
|
||||||
fc_key = (
|
fc_key = (
|
||||||
|
|
@ -107,7 +105,8 @@ def create_file_change_datapoint(
|
||||||
diff=fc_data.get("diff", ""),
|
diff=fc_data.get("diff", ""),
|
||||||
commit_sha=fc_data.get("commit_sha", ""),
|
commit_sha=fc_data.get("commit_sha", ""),
|
||||||
repo=fc_data.get("repo", ""),
|
repo=fc_data.get("repo", ""),
|
||||||
modifies=file,
|
modifies=file.filename,
|
||||||
|
changed_by=user,
|
||||||
belongs_to_set=nodesets,
|
belongs_to_set=nodesets,
|
||||||
)
|
)
|
||||||
logger.debug(f"Created FileChange with ID: {fc_id} for {fc_data.get('filename', '')}")
|
logger.debug(f"Created FileChange with ID: {fc_id} for {fc_data.get('filename', '')}")
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ class FileChange(DataPoint):
|
||||||
diff: str
|
diff: str
|
||||||
commit_sha: str
|
commit_sha: str
|
||||||
repo: str
|
repo: str
|
||||||
modifies: File
|
modifies: str
|
||||||
|
changed_by: GitHubUser
|
||||||
metadata: dict = {"index_fields": ["diff"]}
|
metadata: dict = {"index_fields": ["diff"]}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -67,7 +68,6 @@ class Commit(DataPoint):
|
||||||
commit_url: str
|
commit_url: str
|
||||||
author_name: str
|
author_name: str
|
||||||
repo: str
|
repo: str
|
||||||
authored_by: GitHubUser
|
|
||||||
has_change: List[FileChange] = []
|
has_change: List[FileChange] = []
|
||||||
metadata: dict = {"index_fields": ["commit_message"]}
|
metadata: dict = {"index_fields": ["commit_message"]}
|
||||||
|
|
||||||
|
|
@ -76,5 +76,4 @@ class Repository(DataPoint):
|
||||||
name: str
|
name: str
|
||||||
has_issue: List[Issue] = []
|
has_issue: List[Issue] = []
|
||||||
has_commit: List[Commit] = []
|
has_commit: List[Commit] = []
|
||||||
contains: List[File] = []
|
|
||||||
metadata: dict = {"index_fields": ["name"]}
|
metadata: dict = {"index_fields": ["name"]}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@ def get_or_create_file(
|
||||||
return files[file_key]
|
return files[file_key]
|
||||||
file = create_file_datapoint(filename, repo_name, [technical_nodeset])
|
file = create_file_datapoint(filename, repo_name, [technical_nodeset])
|
||||||
files[file_key] = file
|
files[file_key] = file
|
||||||
link_file_to_repo(file, repository)
|
|
||||||
return file
|
return file
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -137,11 +136,11 @@ def process_file_changes_data(
|
||||||
repository = get_or_create_repository(repo_name, repositories, user, [technical_nodeset])
|
repository = get_or_create_repository(repo_name, repositories, user, [technical_nodeset])
|
||||||
file = get_or_create_file(filename, repo_name, files, repository, technical_nodeset)
|
file = get_or_create_file(filename, repo_name, files, repository, technical_nodeset)
|
||||||
commit = get_or_create_commit(fc_data, user, commits, repository, technical_nodeset)
|
commit = get_or_create_commit(fc_data, user, commits, repository, technical_nodeset)
|
||||||
file_change = create_file_change_datapoint(fc_data, file, [technical_nodeset])
|
file_change = create_file_change_datapoint(fc_data, user, file, [technical_nodeset])
|
||||||
file_changes_list.append(file_change)
|
file_changes_list.append(file_change)
|
||||||
if file_change not in commit.has_change:
|
if file_change not in commit.has_change:
|
||||||
commit.has_change.append(file_change)
|
commit.has_change.append(file_change)
|
||||||
all_datapoints = list(files.values()) + list(commits.values()) + file_changes_list
|
all_datapoints = list(commits.values()) + file_changes_list
|
||||||
return all_datapoints
|
return all_datapoints
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -244,9 +243,9 @@ async def cognify_github_data_from_username(
|
||||||
username: str,
|
username: str,
|
||||||
token: Optional[str] = None,
|
token: Optional[str] = None,
|
||||||
days: int = 30,
|
days: int = 30,
|
||||||
prs_limit: int = 5,
|
prs_limit: int = 3,
|
||||||
commits_per_pr: int = 3,
|
commits_per_pr: int = 3,
|
||||||
issues_limit: int = 5,
|
issues_limit: int = 3,
|
||||||
max_comments: int = 3,
|
max_comments: int = 3,
|
||||||
skip_no_diff: bool = True,
|
skip_no_diff: bool = True,
|
||||||
):
|
):
|
||||||
|
|
@ -300,5 +299,5 @@ if __name__ == "__main__":
|
||||||
# asyncio.run(process_github_from_file(json_file_path))
|
# asyncio.run(process_github_from_file(json_file_path))
|
||||||
#
|
#
|
||||||
# Option 2: Process directly from GitHub
|
# Option 2: Process directly from GitHub
|
||||||
username = "Vasilije1990"
|
username = ""
|
||||||
asyncio.run(cognify_github_data_from_username(username, token))
|
asyncio.run(cognify_github_data_from_username(username, token))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue