diff --git a/app/metrics/assessments_lifespan.py b/app/metrics/assessments_lifespan.py index 80be3ae..4bbd375 100644 --- a/app/metrics/assessments_lifespan.py +++ b/app/metrics/assessments_lifespan.py @@ -21,13 +21,15 @@ async def get_tasks_definitions(app: FastAPI): """ regex = re.compile(r"^CA-RDA-([FAIR][1-9](\.[0-9])?)-") regex_csh = re.compile(r"^CSH-RDA-([FAIR][1-9](\.[0-9])?)-") + regex_joined = re.compile(r"^(CA-RDA|CSH-RDA)-([FAIR][1-9](\.[0-9])?)-") config = get_settings() + print(config) def parse_line(line): - sub_group = regex_csh.search(line["TaskName"]) + sub_group = regex_joined.search(line["TaskName"]) if sub_group is None: return - sub_group = sub_group.groups()[0] + sub_group = sub_group.groups()[1] task_group = sub_group[0] return { line["TaskName"]: models.Indicator( diff --git a/app/models/session.py b/app/models/session.py index 04c4b91..d79dd06 100644 --- a/app/models/session.py +++ b/app/models/session.py @@ -440,7 +440,16 @@ def create_tasks(self): :return: None """ - for indicator in fair_indicators.values(): + # filter fair_indicators for specific session subject + print("checking here") + if self.user_input.subject_type is SubjectType.csh: + name_filter = 'CSH' + else: + name_filter = 'CA' + filter_indicators = {key: value for key, value in fair_indicators.items() if value.name.startswith(name_filter)} + + + for indicator in filter_indicators.values(): # Skip if task for indicator is already created if indicator.name in self.indicator_tasks: continue diff --git a/app/models/tasks.py b/app/models/tasks.py index 1268859..a1565c0 100644 --- a/app/models/tasks.py +++ b/app/models/tasks.py @@ -116,6 +116,8 @@ def has_valid_name(cls, name: str) -> str: :param name: The name given by the user :return: The valid assessment name """ + #filter indicators according to subject + if name not in fair_indicators: raise ValueError(f"Given assessment name {name} is not a known indicator") return name