Skip to content

Commit

Permalink
child view order issue with multi languages
Browse files Browse the repository at this point in the history
  • Loading branch information
nczirjak-acdh committed Aug 27, 2020
1 parent 601d654 commit 322c686
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions inst/dbfunctions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,19 @@ DROP TABLE IF EXISTS child_ids;
(select mv.value from relations as r2 left join metadata_view as mv on r2.target_id = mv.id where r.id = r2.id and r2.property = 'https://vocabs.acdh.oeaw.ac.at/schema#hasAccessRestriction' and
mv.property = 'https://vocabs.acdh.oeaw.ac.at/schema#hasTitle' and mv.lang = _lang) as accessres,
(select mv.value from metadata_view as mv where r.id = mv.id and mv.property = 'https://vocabs.acdh.oeaw.ac.at/schema#hasTitleImage' limit 1) as titleimage,
(select mv.value from metadata_view as mv where r.id = mv.id and mv.property = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' and mv.value like '%vocabs.%' limit 1) as acdhtype
(select mv.value from metadata_view as mv where r.id = mv.id and mv.property = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' and mv.value like '%vocabs.%' limit 1) as acdhtype,
COALESCE(
(select mv.value from metadata_view as mv where mv.id = r.id and mv.property = _orderprop and mv.lang = _lang limit 1),
(select mv.value from metadata_view as mv where mv.id = r.id and mv.property = _orderprop and mv.lang = _lang2 limit 1),
(select mv.value from metadata_view as mv where mv.id = r.id and mv.property = _orderprop limit 1)
) ordervalue
from relations as r
left join identifiers as i on i.id = r.target_id
left join metadata_view as mv on mv.id = r.id
where r.property = ANY (_rdftype)
and mv.property = _orderprop
and i.ids = _parentid
order by
(CASE WHEN _orderby = 'asc' THEN mv.value END) ASC,
mv.value DESC
(CASE WHEN _orderby = 'asc' THEN ordervalue END) ASC,
ordervalue DESC
limit limitint
offset pageint
) select * from ids
Expand Down

0 comments on commit 322c686

Please sign in to comment.