Coverage for src / mesh / models / roles / __init__.py: 100%
8 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-05-04 12:41 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-05-04 12:41 +0000
1from django.contrib.postgres.aggregates import StringAgg
2from django.db import connection
3from django.db.models import CharField, F, Value
4from django.db.models.functions import Concat, Substr
6from mesh.models.orm.submission_models import SubmissionAuthor
8is_sqlite = connection.vendor == "sqlite"
9# Changed during tests
10aggregates_conf = {
11 "authors_string_aggregate": StringAgg(
12 Concat(Substr("authors__first_name", 1, 1), Value(". "), F("authors__last_name")),
13 delimiter=", ",
14 distinct=not is_sqlite,
15 ),
16 "reviewer_string_aggregate": Concat(
17 Substr("reviewer__first_name", 1, 1),
18 Value(". "),
19 F("reviewer__last_name"),
20 Value(" ("),
21 F("reviewer__email"),
22 Value(") "),
23 output_field=CharField(),
24 ),
25}
28authors_qs = SubmissionAuthor.objects.order_by("first_name")