improve grouping server side
This commit is contained in:
+10
-1
@@ -12,6 +12,7 @@ from django.db.models.fields.related import ForeignKey
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.core.cache import cache
|
||||||
|
|
||||||
|
|
||||||
import pydicom
|
import pydicom
|
||||||
@@ -129,6 +130,11 @@ def _normalise_group_rule_value(value):
|
|||||||
|
|
||||||
|
|
||||||
def _build_declared_series_groups(series, series_images_with_urls):
|
def _build_declared_series_groups(series, series_images_with_urls):
|
||||||
|
cache_key = f"atlas:series_declared_groups:{series.pk}:{int(series.modified_date.timestamp())}:{len(series_images_with_urls)}"
|
||||||
|
cached = cache.get(cache_key)
|
||||||
|
if cached is not None:
|
||||||
|
return cached
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
"dwiBValue",
|
"dwiBValue",
|
||||||
"dwiDirection",
|
"dwiDirection",
|
||||||
@@ -189,7 +195,7 @@ def _build_declared_series_groups(series, series_images_with_urls):
|
|||||||
active_rules.append(rule_id)
|
active_rules.append(rule_id)
|
||||||
|
|
||||||
if len(active_rules) == 0:
|
if len(active_rules) == 0:
|
||||||
return [
|
result = [
|
||||||
{
|
{
|
||||||
"key": f"SERVER_SERIES_{series.pk}_0",
|
"key": f"SERVER_SERIES_{series.pk}_0",
|
||||||
"label": "Series 1",
|
"label": "Series 1",
|
||||||
@@ -199,6 +205,8 @@ def _build_declared_series_groups(series, series_images_with_urls):
|
|||||||
"groupValues": {},
|
"groupValues": {},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
cache.set(cache_key, result, timeout=60 * 60)
|
||||||
|
return result
|
||||||
|
|
||||||
grouped = {}
|
grouped = {}
|
||||||
for row in rows:
|
for row in rows:
|
||||||
@@ -253,6 +261,7 @@ def _build_declared_series_groups(series, series_images_with_urls):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cache.set(cache_key, ordered_groups, timeout=60 * 60)
|
||||||
return ordered_groups
|
return ordered_groups
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+90
-90
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user