@@ -209,6 +209,7 @@ export class LanguageRepository extends DtoRepository<
209209 ] )
210210 . apply ( matchProps ( { nodeName : 'eth' , outputVar : 'ethProps' } ) )
211211 . apply ( isPresetInventory )
212+ . apply ( usingAIAssistance )
212213 . optionalMatch ( [
213214 node ( 'node' ) ,
214215 relation ( 'in' , '' , 'language' , ACTIVE ) ,
@@ -222,6 +223,7 @@ export class LanguageRepository extends DtoRepository<
222223 ethnologue : 'ethProps' ,
223224 pinned,
224225 presetInventory : 'presetInventory' ,
226+ usesAIAssistance : 'coalesce(usesAIAssistance, false)' ,
225227 firstScriptureEngagement : 'firstScriptureEngagement { .id }' ,
226228 scope : 'scopedRoles' ,
227229 changeset : 'changeset.id' ,
@@ -339,6 +341,10 @@ export const languageFilters = filter.define(() => LanguageFilters, {
339341 const condition = equals ( 'true' , true ) ;
340342 return { presetInventory : value ? condition : not ( condition ) } ;
341343 } ,
344+ usesAIAssistance : ( { value, query } ) => {
345+ query . apply ( usingAIAssistance ) . with ( [ 'node' , 'usesAIAssistance' ] ) ;
346+ return { usesAIAssistance : value } ;
347+ } ,
342348} ) ;
343349
344350const ethnologueFilters = filter . define ( ( ) => EthnologueLanguageFilters , {
@@ -374,6 +380,25 @@ const isPresetInventory = (query: Query) =>
374380 ) ,
375381 ) ;
376382
383+ const usingAIAssistance = ( query : Query ) =>
384+ query . subQuery ( 'node' , ( sub ) =>
385+ sub
386+ . optionalMatch ( [
387+ node ( 'node' ) ,
388+ relation ( 'in' , '' , 'language' , ACTIVE ) ,
389+ node ( 'eng' , 'LanguageEngagement' ) ,
390+ ] )
391+ . optionalMatch ( [
392+ node ( 'eng' ) ,
393+ relation ( 'out' , '' , 'usingAIAssistedTranslation' , ACTIVE ) ,
394+ node ( 'prop' , 'Property' ) ,
395+ ] )
396+ . with ( [
397+ `any(val in collect(prop.value) WHERE val IS NOT NULL AND val <> 'None' AND val <> 'Unknown') as usesAIAssistance` ,
398+ ] )
399+ . return ( [ 'usesAIAssistance' ] ) ,
400+ ) ;
401+
377402export const languageSorters = defineSorters ( Language , {
378403 // eslint-disable-next-line @typescript-eslint/naming-convention
379404 'ethnologue.*' : ( query , input ) =>
@@ -405,6 +430,11 @@ export const languageSorters = defineSorters(Language, {
405430 . return < { sortValue : unknown } > (
406431 coalesce ( 'override.value' , 'canonical.value' ) . as ( 'sortValue' ) ,
407432 ) ,
433+ usesAIAssistance : ( query ) =>
434+ query
435+ . apply ( usingAIAssistance )
436+ . with ( [ 'node' , 'usesAIAssistance as sortValue' ] )
437+ . return < { sortValue : unknown } > ( 'sortValue' ) ,
408438} ) ;
409439
410440const ethnologueSorters = defineSorters ( EthnologueLanguage , { } ) ;
0 commit comments