Merge pull request 'fix: sort order in acupoints' (#14) from fix/preserve-content-authoring-sort-order into main
Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-api/pulls/14 Reviewed-by: Amit Salunke <amit@noreply.localhost>
This commit is contained in:
commit
ba1e5cd04c
|
|
@ -121,8 +121,17 @@ class ModuleSeeder:
|
||||||
from {self._schema}.content_items ci
|
from {self._schema}.content_items ci
|
||||||
join {self._schema}.attribute_definition_sets ads
|
join {self._schema}.attribute_definition_sets ads
|
||||||
on ads.id = ci.attribute_definition_set_id
|
on ads.id = ci.attribute_definition_set_id
|
||||||
|
left join {self._schema}.content_attributes ca
|
||||||
|
on ca.content_id = ci.id
|
||||||
|
and ca.attribute_definition_id = (
|
||||||
|
select id
|
||||||
|
from {self._schema}.attribute_definitions
|
||||||
|
where attribute_definition_set_id = ads.id
|
||||||
|
and code = 'sort_order'
|
||||||
|
limit 1
|
||||||
|
)
|
||||||
where ads.code = :definition_set_code
|
where ads.code = :definition_set_code
|
||||||
order by ci.sort_title asc, ci.id asc
|
order by ca.value_number asc nulls last, ci.sort_title asc, ci.id asc
|
||||||
"""),
|
"""),
|
||||||
{"definition_set_code": definition_set_code},
|
{"definition_set_code": definition_set_code},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,16 @@ class SeedOrchestrator:
|
||||||
# seeded by this invocation are candidates for module
|
# seeded by this invocation are candidates for module
|
||||||
# association. Never rewrite unrelated template rows.
|
# association. Never rewrite unrelated template rows.
|
||||||
content_ids = [result.content_id for result in batch.results]
|
content_ids = [result.content_id for result in batch.results]
|
||||||
|
elif batch.results:
|
||||||
|
# Preserve authored sequence from the source document.
|
||||||
|
content_ids = [result.content_id for result in batch.results]
|
||||||
|
known_ids = set(content_ids)
|
||||||
|
all_ids = await self._modules.resolve_content_ids_for_definition_set(
|
||||||
|
definition_set_code=mapping.code
|
||||||
|
)
|
||||||
|
for remaining_id in all_ids:
|
||||||
|
if remaining_id not in known_ids:
|
||||||
|
content_ids.append(remaining_id)
|
||||||
else:
|
else:
|
||||||
content_ids = await self._modules.resolve_content_ids_for_definition_set(
|
content_ids = await self._modules.resolve_content_ids_for_definition_set(
|
||||||
definition_set_code=mapping.code
|
definition_set_code=mapping.code
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue