Skip to content

Commit

Permalink
fixed duplicates in solved incidents (#30)
Browse files Browse the repository at this point in the history
Signed-off-by: Savitha Raghunathan <saveetha13@gmail.com>
  • Loading branch information
savitharaghunathan authored Feb 16, 2024
1 parent 4fd5d20 commit 620a9a4
Show file tree
Hide file tree
Showing 2 changed files with 320 additions and 1,493 deletions.
79 changes: 42 additions & 37 deletions kai/incident_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def update_incident_store(self, app_name):
report = IncidentStore.create_temp_cached_violations(app_name, temp_report)
self.missing_violations = self.get_missing_incidents(app_name, report)

self.solved_violations = self.find_solved_issues()
self.solved_violations = self.find_solved_issues(app_name)

for ruleset in report.keys():
if ruleset not in cached_violations:
Expand Down Expand Up @@ -644,7 +644,7 @@ def get_missing_incidents(self, app_name, new_report):

return self.missing_violations

def find_solved_issues(self):
def find_solved_issues(self, app_name):
"""
Find solved issues from the missing incidents
"""
Expand All @@ -653,46 +653,51 @@ def find_solved_issues(self):
for ruleset in self.missing_violations.keys():
for violation in self.missing_violations[ruleset].keys():
for app in self.missing_violations[ruleset][violation].keys():
repo_path = IncidentStore.get_repo_path(app)
for file_path in self.missing_violations[ruleset][violation][
app
].keys():
for incident in self.missing_violations[ruleset][violation][
if app == app_name:
repo_path = IncidentStore.get_repo_path(app)
for file_path in self.missing_violations[ruleset][violation][
app
][file_path]:
# find the solved issue
git_helper = GitHelper(
incident["repo"],
repo_path,
incident["initial_branch"],
incident["solved_branch"],
incident["commitId"],
incident["new_commitId"],
)
].keys():
for incident in self.missing_violations[ruleset][violation][
app
][file_path]:
# find the solved issue
git_helper = GitHelper(
incident["repo"],
repo_path,
incident["initial_branch"],
incident["solved_branch"],
incident["commitId"],
incident["new_commitId"],
)

diff_exists = git_helper.diff_exists_for_file(file_path)
if diff_exists:
if ruleset not in self.solved_violations:
self.solved_violations[ruleset] = {}
if violation not in self.solved_violations[ruleset]:
self.solved_violations[ruleset][violation] = {}
if (
app
not in self.solved_violations[ruleset][violation]
):
self.solved_violations[ruleset][violation][app] = {}
if (
file_path
not in self.solved_violations[ruleset][violation][
diff_exists = git_helper.diff_exists_for_file(file_path)
if diff_exists:
if ruleset not in self.solved_violations:
self.solved_violations[ruleset] = {}
if violation not in self.solved_violations[ruleset]:
self.solved_violations[ruleset][violation] = {}
if (
app
]
):
not in self.solved_violations[ruleset][
violation
]
):
self.solved_violations[ruleset][violation][
app
] = {}
if (
file_path
not in self.solved_violations[ruleset][
violation
][app]
):
self.solved_violations[ruleset][violation][app][
file_path
] = []
self.solved_violations[ruleset][violation][app][
file_path
] = []
self.solved_violations[ruleset][violation][app][
file_path
].append(incident)
].append(incident)
return self.solved_violations

def get_repo_path(app_name):
Expand Down
Loading

0 comments on commit 620a9a4

Please sign in to comment.