@@ -5,7 +5,6 @@ import { IRepositoryOptions } from './IRepositoryOptions'
55import { RepositoryBase } from './repositoryBase'
66import {
77 SegmentCreateData ,
8- SegmentCriteria ,
98 SegmentData ,
109 SegmentLevel ,
1110 SegmentProjectGroupNestedData ,
@@ -48,7 +47,7 @@ class SegmentRepository extends RepositoryBase<
4847 {
4948 replacements : {
5049 id : uuid ( ) ,
51- url : data . url ,
50+ url : data . url || null ,
5251 name : data . name ,
5352 parentName : data . parentName || null ,
5453 grandparentName : data . grandparentName || null ,
@@ -402,7 +401,7 @@ class SegmentRepository extends RepositoryBase<
402401 }
403402
404403 if ( criteria . filter ?. name ) {
405- searchQuery += `AND s.name like :name`
404+ searchQuery += `AND s.name ilike :name`
406405 }
407406
408407 const projectGroups = await this . options . database . sequelize . query (
@@ -447,7 +446,7 @@ class SegmentRepository extends RepositoryBase<
447446 } ,
448447 )
449448
450- const count = projectGroups . length > 0 ? projectGroups [ 0 ] . totalCount : 0
449+ const count = projectGroups . length > 0 ? Number . parseInt ( projectGroups [ 0 ] . totalCount , 10 ) : 0
451450
452451 const rows = projectGroups . map ( ( i ) => removeFieldsFromObject ( i , 'totalCount' ) )
453452
@@ -464,7 +463,11 @@ class SegmentRepository extends RepositoryBase<
464463 }
465464
466465 if ( criteria . filter ?. name ) {
467- searchQuery += ` AND s.name like :name`
466+ searchQuery += ` AND s.name ilike :name`
467+ }
468+
469+ if ( criteria . filter ?. parentSlug ) {
470+ searchQuery += ` AND s."parentSlug" ilike :parent_slug `
468471 }
469472
470473 const projects = await this . options . database . sequelize . query (
@@ -487,12 +490,13 @@ class SegmentRepository extends RepositoryBase<
487490 replacements : {
488491 name : `${ criteria . filter ?. name } %` ,
489492 status : criteria . filter ?. status ,
493+ parent_slug : `${ criteria . filter ?. parentSlug } %` ,
490494 } ,
491495 type : QueryTypes . SELECT ,
492496 } ,
493497 )
494498
495- const count = projects . length > 0 ? projects [ 0 ] . totalCount : 0
499+ const count = projects . length > 0 ? Number . parseInt ( projects [ 0 ] . totalCount , 10 ) : 0
496500
497501 const rows = projects . map ( ( i ) => removeFieldsFromObject ( i , 'totalCount' ) )
498502
@@ -514,7 +518,15 @@ class SegmentRepository extends RepositoryBase<
514518 }
515519
516520 if ( criteria . filter ?. name ) {
517- searchQuery += ` AND s.name like :name`
521+ searchQuery += ` AND s.name ilike :name`
522+ }
523+
524+ if ( criteria . filter ?. parentSlug ) {
525+ searchQuery += ` AND s."parentSlug" ilike :parent_slug `
526+ }
527+
528+ if ( criteria . filter ?. grandparentSlug ) {
529+ searchQuery += ` AND s."grandparentSlug" ilike :grandparent_slug `
518530 }
519531
520532 const subprojects = await this . options . database . sequelize . query (
@@ -534,12 +546,14 @@ class SegmentRepository extends RepositoryBase<
534546 tenantId : this . currentTenant . id ,
535547 name : `${ criteria . filter ?. name } %` ,
536548 status : criteria . filter ?. status ,
549+ parent_slug : `${ criteria . filter ?. parentSlug } %` ,
550+ grandparent_slug : `${ criteria . filter ?. grandparentSlug } %` ,
537551 } ,
538552 type : QueryTypes . SELECT ,
539553 } ,
540554 )
541555
542- const count = subprojects . length > 0 ? subprojects [ 0 ] . totalCount : 0
556+ const count = subprojects . length > 0 ? Number . parseInt ( subprojects [ 0 ] . totalCount , 10 ) : 0
543557
544558 const rows = subprojects . map ( ( i ) => {
545559 const subproject = removeFieldsFromObject ( i , 'totalCount' )
0 commit comments