Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Zammad plugin by filtering tickets after search #328

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

come-nc
Copy link
Contributor

@come-nc come-nc commented Sep 25, 2023

The API query is not searching correctly and is returning more tickets that it should, so we loop on them and get articles from the API to filter which one were actually updated in the time range.

This reduces false positive a lot.

Copy link
Owner

@psss psss left a comment

Choose a reason for hiding this comment

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

Thanks for improving this! Looks good, just two minor suggestions. Consider enabling pre-commit to catch code style errors early, see also the develop section.

except urllib.error.URLError as error:
log.debug(error)
raise ReportError(
"Zammad search on {0} failed.".format(self.url))
Copy link
Owner

Choose a reason for hiding this comment

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

This part seems to be copy & pasted from the search() method. What about separating the common code to prevent duplication? There could be a common search() method used by both get_articles() and get_tickets(). What do you think, @come-nc?

for _,ticket in self.parent.zammad.search(query).items():
for article in self.parent.zammad.get_articles(ticket["id"]):
updated_at = datetime.fromisoformat(article["updated_at"].replace('Z', '+00:00')).date()
if (article["created_by"] == self.user.email) and (updated_at >= self.options.since.date) and (updated_at <= self.options.until.date):
Copy link
Owner

Choose a reason for hiding this comment

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

Please, wrap the long line to make pre-commit happy. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants