Skip to content
Open
Changes from all 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
2 changes: 2 additions & 0 deletions packit_service/worker/helpers/testing_farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,7 @@ def _get_tf_base_payload(self, distro: str, compose: Optional[str]) -> dict:
# this has to be specified at the api request level.
# TODO: Revisit when 0.2 testing-farm API is decided
os_params = {"os": {"compose": compose}} if compose else {}
dist_git_branch = self.project.get_pr(self.metadata.pr_id).target_branch
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This call to self.project.get_pr(self.metadata.pr_id) makes a network request. Since _get_tf_base_payload can be called multiple times within a single job run (e.g., for rpminspect and custom tests), this can lead to redundant API calls.

To improve efficiency, I suggest caching the pull request object on the helper instance. This ensures the PR is fetched only once per job run.

I've also noticed that _payload_custom makes a similar call. After applying this suggestion, you could refactor it to use the cached self._pr_object as well.

        if not hasattr(self, "_pr_object"):
            self._pr_object = self.project.get_pr(self.metadata.pr_id)
        dist_git_branch = self._pr_object.target_branch

return {
"environments": [
{
Expand All @@ -1532,6 +1533,7 @@ def _get_tf_base_payload(self, distro: str, compose: Optional[str]) -> dict:
"arch": "x86_64",
"trigger": "commit",
"initiator": "fedora-ci",
"dist-git-branch": dist_git_branch,
}
},
},
Expand Down
Loading