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

client: Cache raw field information #1798

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
12 changes: 11 additions & 1 deletion jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,16 @@ def __init__(
JIRA.checked_version = True

self._fields_cache_value: dict[str, str] = {} # access via self._fields_cache
self._fields_cache_value_raw: list[
dict[str, Any]
] = [] # access via self._fields_cache_raw

@property
def _fields_cache_raw(self) -> list[dict[str, Any]]:
"""Cached raw dictionary of of /field endpoint. Lazy loaded."""
if not self._fields_cache_value_raw:
self._fields_cache_value_raw = self.fields()
return self._fields_cache_value_raw

@property
def _fields_cache(self) -> dict[str, str]:
Expand All @@ -683,7 +693,7 @@ def _fields_cache(self) -> dict[str, str]:
def _update_fields_cache(self):
"""Update the cache used for `self._fields_cache`."""
self._fields_cache_value = {}
for f in self.fields():
for f in self._fields_cache_raw:
if "clauseNames" in f:
for name in f["clauseNames"]:
self._fields_cache_value[name] = f["id"]
Expand Down
Loading