Skip to content

Commit

Permalink
fixing filter + reducing api cost
Browse files Browse the repository at this point in the history
  • Loading branch information
ronykoz committed May 20, 2020
1 parent dbf2c2b commit dff822d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions src/github_automation/management/event_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def is_matching_issue(issue_labels, must_have_labels, cant_have_labels, filter_l
for label in must_have_labels:
if OR in label:
new_labels = label.split(OR)
if not any(new_label not in issue_labels for new_label in new_labels):
if all(new_label not in issue_labels for new_label in new_labels):
return False

elif label not in issue_labels:
Expand Down Expand Up @@ -90,23 +90,23 @@ def manage_issue_in_project(self, issue):
return

matching_column_name = Project.get_matching_column(issue, self.config)
project = self.load_project_column(matching_column_name)

if self.config.add and self.config.project_number not in issue.get_associated_project():
project = self.load_project_column(matching_column_name)
project.add_issue(self.client, issue, matching_column_name, self.config)
return

if (self.config.add and not all(project.get_current_location(issue.id)) # The issue is in the triage
or self.config.move):
column_name_before, _ = project.get_current_location(issue.id)
if column_name_before != matching_column_name:
project.move_issue(self.client, issue, matching_column_name, self.config)
return

if self.config.sort:
column_name_before, _ = project.get_current_location(issue.id)
if column_name_before == matching_column_name:
project.columns[matching_column_name].sort_cards(self.client, self.config)
column_name_before = [value['project_column'] for _id, value in issue.card_id_project.items()
if value['project_number'] == self.config.project_number][0]
if (self.config.add and not column_name_before) or \
(self.config.move and matching_column_name != column_name_before):
project = self.load_project_column(matching_column_name)
project.move_issue(self.client, issue, matching_column_name, self.config)
return

if self.config.sort and column_name_before == matching_column_name:
project = self.load_project_column(matching_column_name)
project.columns[matching_column_name].sort_cards(self.client, self.config)

return

Expand Down
2 changes: 1 addition & 1 deletion src/github_automation/management/project_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def is_matching_issue(issue_labels, must_have_labels, cant_have_labels, filter_l
for label in must_have_labels:
if OR in label:
new_labels = label.split(OR)
if not any(new_label not in issue_labels for new_label in new_labels):
if all(new_label not in issue_labels for new_label in new_labels):
return False

elif label not in issue_labels:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_files/event_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_matching_issue_filter():
assert EventManager.is_matching_issue(['not bug', 'something'], config.must_have_labels, config.cant_have_labels,
config.filter_labels) is True
assert EventManager.is_matching_issue(['not bug', 'else'], config.must_have_labels, config.cant_have_labels,
config.filter_labels) is True
config.filter_labels) is False


def test_get_prev_column():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_files/project_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,4 @@ def test_matching_issue_filter():
assert ProjectManager.is_matching_issue(['not bug', 'something'], config.must_have_labels, config.cant_have_labels,
config.filter_labels) is True
assert ProjectManager.is_matching_issue(['not bug', 'else'], config.must_have_labels, config.cant_have_labels,
config.filter_labels) is True
config.filter_labels) is False

0 comments on commit dff822d

Please sign in to comment.