Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
331bef2d
Verified
Commit
331bef2d
authored
6 years ago
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #8956 Filters accent + entities children count + categories
parent
9dd3b086
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/resource/controllers/ResourceListController.php
+61
-41
61 additions, 41 deletions
src/app/resource/controllers/ResourceListController.php
with
61 additions
and
41 deletions
src/app/resource/controllers/ResourceListController.php
+
61
−
41
View file @
331bef2d
...
@@ -57,7 +57,7 @@ class ResourceListController
...
@@ -57,7 +57,7 @@ class ResourceListController
$where
[]
=
'process_limit_date < CURRENT_TIMESTAMP'
;
$where
[]
=
'process_limit_date < CURRENT_TIMESTAMP'
;
}
}
if
(
!
empty
(
$data
[
'search'
])
&&
mb_strlen
(
$data
[
'search'
])
>=
2
)
{
if
(
!
empty
(
$data
[
'search'
])
&&
mb_strlen
(
$data
[
'search'
])
>=
2
)
{
$where
[]
=
'(alt_identifier ilike ? OR translate(subject, \'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ\', \'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyrr\') ilike
?
)'
;
$where
[]
=
'(alt_identifier ilike ? OR translate(subject, \'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ\', \'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyrr\') ilike
translate(?, \'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ\', \'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyrr\')
)'
;
$queryData
[]
=
"%
{
$data
[
'search'
]
}
%"
;
$queryData
[]
=
"%
{
$data
[
'search'
]
}
%"
;
$queryData
[]
=
"%
{
$data
[
'search'
]
}
%"
;
$queryData
[]
=
"%
{
$data
[
'search'
]
}
%"
;
}
}
...
@@ -153,7 +153,7 @@ class ResourceListController
...
@@ -153,7 +153,7 @@ class ResourceListController
$where
[]
=
'process_limit_date < CURRENT_TIMESTAMP'
;
$where
[]
=
'process_limit_date < CURRENT_TIMESTAMP'
;
}
}
if
(
!
empty
(
$data
[
'search'
])
&&
mb_strlen
(
$data
[
'search'
])
>=
2
)
{
if
(
!
empty
(
$data
[
'search'
])
&&
mb_strlen
(
$data
[
'search'
])
>=
2
)
{
$where
[]
=
'(alt_identifier ilike ? OR translate(subject, \'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ\', \'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyrr\') ilike
?
)'
;
$where
[]
=
'(alt_identifier ilike ? OR translate(subject, \'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ\', \'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyrr\') ilike
translate(?, \'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ\', \'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyrr\')
)'
;
$queryData
[]
=
"%
{
$data
[
'search'
]
}
%"
;
$queryData
[]
=
"%
{
$data
[
'search'
]
}
%"
;
$queryData
[]
=
"%
{
$data
[
'search'
]
}
%"
;
$queryData
[]
=
"%
{
$data
[
'search'
]
}
%"
;
}
}
...
@@ -216,24 +216,6 @@ class ResourceListController
...
@@ -216,24 +216,6 @@ class ResourceListController
}
}
}
}
$entities
=
[];
$rawEntities
=
ResModel
::
getOnView
([
'select'
=>
[
'count(res_id)'
,
'destination'
],
'where'
=>
$whereEntities
,
'data'
=>
$dataEntities
,
'groupBy'
=>
[
'destination'
]
]);
foreach
(
$rawEntities
as
$key
=>
$value
)
{
if
(
!
empty
(
$value
[
'destination'
]))
{
$entity
=
EntityModel
::
getByEntityId
([
'select'
=>
[
'entity_label'
],
'entityId'
=>
$value
[
'destination'
]]);
$entities
[]
=
[
'entityId'
=>
$value
[
'destination'
],
'label'
=>
$entity
[
'entity_label'
],
'count'
=>
$value
[
'count'
]
];
}
}
$priorities
=
[];
$priorities
=
[];
$rawPriorities
=
ResModel
::
getOnView
([
$rawPriorities
=
ResModel
::
getOnView
([
'select'
=>
[
'count(res_id)'
,
'priority'
],
'select'
=>
[
'count(res_id)'
,
'priority'
],
...
@@ -242,14 +224,15 @@ class ResourceListController
...
@@ -242,14 +224,15 @@ class ResourceListController
'groupBy'
=>
[
'priority'
]
'groupBy'
=>
[
'priority'
]
]);
]);
foreach
(
$rawPriorities
as
$key
=>
$value
)
{
foreach
(
$rawPriorities
as
$key
=>
$value
)
{
$priority
=
null
;
if
(
!
empty
(
$value
[
'priority'
]))
{
if
(
!
empty
(
$value
[
'priority'
]))
{
$priority
=
PriorityModel
::
getById
([
'select'
=>
[
'label'
],
'id'
=>
$value
[
'priority'
]]);
$priority
=
PriorityModel
::
getById
([
'select'
=>
[
'label'
],
'id'
=>
$value
[
'priority'
]]);
$priorities
[]
=
[
'id'
=>
$value
[
'priority'
],
'label'
=>
$priority
[
'label'
],
'count'
=>
$value
[
'count'
]
];
}
}
$priorities
[]
=
[
'id'
=>
empty
(
$value
[
'priority'
])
?
null
:
$value
[
'priority'
],
'label'
=>
empty
(
$priority
[
'label'
])
?
null
:
$priority
[
'label'
],
'count'
=>
$value
[
'count'
]
];
}
}
$categories
=
[];
$categories
=
[];
...
@@ -261,15 +244,19 @@ class ResourceListController
...
@@ -261,15 +244,19 @@ class ResourceListController
'groupBy'
=>
[
'category_id'
]
'groupBy'
=>
[
'category_id'
]
]);
]);
foreach
(
$rawCategories
as
$key
=>
$value
)
{
foreach
(
$rawCategories
as
$key
=>
$value
)
{
foreach
(
$allCategories
as
$category
)
{
$label
=
null
;
if
(
$value
[
'category_id'
]
==
$category
[
'id'
])
{
if
(
!
empty
(
$value
[
'category_id'
]))
{
$categories
[]
=
[
foreach
(
$allCategories
as
$category
)
{
'id'
=>
$value
[
'category_id'
],
if
(
$value
[
'category_id'
]
==
$category
[
'id'
])
{
'label'
=>
$category
[
'label'
],
$label
=
$category
[
'label'
];
'count'
=>
$value
[
'count'
]
}
];
}
}
}
}
$categories
[]
=
[
'id'
=>
empty
(
$value
[
'category_id'
])
?
null
:
$value
[
'category_id'
],
'label'
=>
empty
(
$label
)
?
null
:
$label
,
'count'
=>
$value
[
'count'
]
];
}
}
$statuses
=
[];
$statuses
=
[];
...
@@ -280,22 +267,55 @@ class ResourceListController
...
@@ -280,22 +267,55 @@ class ResourceListController
'groupBy'
=>
[
'status'
]
'groupBy'
=>
[
'status'
]
]);
]);
foreach
(
$rawStatuses
as
$key
=>
$value
)
{
foreach
(
$rawStatuses
as
$key
=>
$value
)
{
if
(
!
empty
(
$value
[
'status'
]))
{
$status
=
StatusModel
::
getById
([
'select'
=>
[
'label_status'
],
'id'
=>
$value
[
'status'
]]);
$status
=
StatusModel
::
getById
([
'select'
=>
[
'label_status'
],
'id'
=>
$value
[
'status'
]]);
$statuses
[]
=
[
$statuses
[]
=
[
'id'
=>
$value
[
'status'
],
'id'
=>
$value
[
'status'
],
'label'
=>
empty
(
$status
[
'label_status'
])
?
null
:
$status
[
'label_status'
],
'label'
=>
$status
[
'label_status'
],
'count'
=>
$value
[
'count'
]
'count'
=>
$value
[
'count'
]
];
];
}
$entities
=
[];
$rawEntities
=
ResModel
::
getOnView
([
'select'
=>
[
'count(res_id)'
,
'destination'
],
'where'
=>
$whereEntities
,
'data'
=>
$dataEntities
,
'groupBy'
=>
[
'destination'
]
]);
foreach
(
$rawEntities
as
$key
=>
$value
)
{
$entity
=
null
;
if
(
!
empty
(
$value
[
'destination'
]))
{
$entity
=
EntityModel
::
getByEntityId
([
'select'
=>
[
'entity_label'
],
'entityId'
=>
$value
[
'destination'
]]);
}
}
$entities
[]
=
[
'entityId'
=>
empty
(
$value
[
'destination'
])
?
null
:
$value
[
'destination'
],
'label'
=>
empty
(
$entity
[
'entity_label'
])
?
null
:
$entity
[
'entity_label'
],
'count'
=>
$value
[
'count'
]
];
}
}
$entities
=
(
count
(
$entities
)
>=
2
)
?
$entities
:
[];
$priorities
=
(
count
(
$priorities
)
>=
2
)
?
$priorities
:
[];
$priorities
=
(
count
(
$priorities
)
>=
2
)
?
$priorities
:
[];
$categories
=
(
count
(
$categories
)
>=
2
)
?
$categories
:
[];
$categories
=
(
count
(
$categories
)
>=
2
)
?
$categories
:
[];
$statuses
=
(
count
(
$statuses
)
>=
2
)
?
$statuses
:
[];
$statuses
=
(
count
(
$statuses
)
>=
2
)
?
$statuses
:
[];
$entities
=
(
count
(
$entities
)
>=
2
)
?
$entities
:
[];
$entitiesChildren
=
[];
foreach
(
$entities
as
$entity
)
{
$children
=
EntityModel
::
getEntityChildren
([
'entityId'
=>
$entity
[
'entityId'
]]);
$count
=
0
;
foreach
(
$entities
as
$value
)
{
if
(
in_array
(
$value
[
'entityId'
],
$children
))
{
$count
+=
$value
[
'count'
];
}
}
$entitiesChildren
[]
=
[
'entityId'
=>
$entity
[
'entityId'
],
'label'
=>
$entity
[
'label'
],
'count'
=>
$count
];
}
return
$response
->
withJson
([
'entities'
=>
$entities
,
'priorities'
=>
$priorities
,
'categories'
=>
$categories
,
'statuses'
=>
$statuses
]);
return
$response
->
withJson
([
'entities'
=>
$entities
,
'priorities'
=>
$priorities
,
'categories'
=>
$categories
,
'statuses'
=>
$statuses
,
'entitiesChildren'
=>
$entitiesChildren
]);
}
}
private
static
function
listControl
(
array
$aArgs
)
private
static
function
listControl
(
array
$aArgs
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment