mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 03:46:25 -06:00
Apply the path__in filter to avoid duplicating code
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
9930fef28b
commit
5173a490b8
@ -30,15 +30,14 @@ class DataFileLoader(BaseLoader):
|
|||||||
# Find and pre-fetch referenced templates
|
# Find and pre-fetch referenced templates
|
||||||
if referenced_templates := tuple(find_referenced_templates(environment.parse(template_source))):
|
if referenced_templates := tuple(find_referenced_templates(environment.parse(template_source))):
|
||||||
if None in referenced_templates:
|
if None in referenced_templates:
|
||||||
self.cache_templates({
|
related_files = DataFile.objects.filter(source=self.data_source)
|
||||||
df.path: df.data_as_string for df in
|
# None indicates the use of dynamic resolution. If dependent files are statically
|
||||||
DataFile.objects.filter(source=self.data_source)
|
# defined, we can filter by path for optimization.
|
||||||
})
|
if None not in referenced_templates:
|
||||||
else:
|
related_files = related_files.filter(path__in=referenced_templates)
|
||||||
self.cache_templates({
|
self.cache_templates({
|
||||||
df.path: df.data_as_string for df in
|
df.path: df.data_as_string for df in related_files
|
||||||
DataFile.objects.filter(source=self.data_source, path__in=referenced_templates)
|
})
|
||||||
})
|
|
||||||
|
|
||||||
return template_source, template, lambda: True
|
return template_source, template, lambda: True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user