[Management] Provide a way to fetch index pattern titles#13030
[Management] Provide a way to fetch index pattern titles#13030chrisronline merged 3 commits intoelastic:masterfrom
Conversation
…ndex patterns, specifically the `title` or name
src/ui/public/index_patterns/_get.js
Outdated
| cachedPromise = null; | ||
| return (field) => { | ||
| const getter = get.bind(get, field); | ||
| getter.clearCache = function () { |
There was a problem hiding this comment.
Previously the IndexPatternsProvider would clear the complete cache whenever it was invalidated. With this change, only the part of the cache used by the respective user is cleared. This seems like a dangerous way to end up with everything sitting in memory forever.
I wonder if we should only cache IDs, and simply fetch other things on demand?
There was a problem hiding this comment.
Yup great point. I'm honestly not sure if caching will provide much benefit as it's not clear how consumers will use this for non-ids, but it made sense to me (at the time) to keep the behavior consistent. The previous callers to clearCache were only clearing cache around ids so it felt odd to clear the entire cache, but that might be the right call, or as you eluded to, maybe just not bother caching non-ids requests entirely.
I'm open to changing it.
|
@pickypg Went ahead and made that change |
pickypg
left a comment
There was a problem hiding this comment.
LGTM. I'm not that familiar with this code though. It would be nice to have some tests though?
|
LGTM |
* Refactor how `get_ids` works to enable fetching other properties of index patterns, specifically the `title` or name * Remove unnecessary lines * Only cache for `id` calls
* Refactor how `get_ids` works to enable fetching other properties of index patterns, specifically the `title` or name * Remove unnecessary lines * Only cache for `id` calls
* Refactor how `get_ids` works to enable fetching other properties of index patterns, specifically the `title` or name * Remove unnecessary lines * Only cache for `id` calls
Summary: This PR adds another method to the
indexPatternsservice to fetch index patterns titles. Since the code was nearly identical to how index pattern ids are fetched, I decided to slightly refactor the function to accept a parameter for which property to fetch from the index pattern. I've updated all usages to the new approach.