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
ce7ea753
Verified
Commit
ce7ea753
authored
5 years ago
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #12869 TIME 0:50 Search count + all ids
parent
a0ae7ee5
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/search/controllers/SearchController.php
+37
-10
37 additions, 10 deletions
src/app/search/controllers/SearchController.php
with
37 additions
and
10 deletions
src/app/search/controllers/SearchController.php
+
37
−
10
View file @
ce7ea753
...
@@ -17,6 +17,7 @@ namespace Search\controllers;
...
@@ -17,6 +17,7 @@ namespace Search\controllers;
use
Attachment\models\AttachmentModel
;
use
Attachment\models\AttachmentModel
;
use
Basket\models\BasketModel
;
use
Basket\models\BasketModel
;
use
Basket\models\RedirectBasketModel
;
use
Basket\models\RedirectBasketModel
;
use
Doctype\models\DoctypeModel
;
use
Priority\models\PriorityModel
;
use
Priority\models\PriorityModel
;
use
Resource\models\ResModel
;
use
Resource\models\ResModel
;
use
Resource\models\ResourceContactModel
;
use
Resource\models\ResourceContactModel
;
...
@@ -143,20 +144,38 @@ class SearchController
...
@@ -143,20 +144,38 @@ class SearchController
$offset
=
(
int
)
$queryParams
[
'offset'
];
$offset
=
(
int
)
$queryParams
[
'offset'
];
}
}
$resources
=
ResModel
::
getOnView
([
$allResources
=
ResModel
::
getOnView
([
'select'
=>
[
'select'
=>
[
'res_id as "resId"'
],
'res_id as "resId"'
,
'alt_identifier as "chrono"'
,
'subject'
,
'barcode'
,
'filename'
,
'creation_date as "creationDate"'
,
'type_id as "type"'
,
'priority'
,
'status'
,
'dest_user as "destUser"'
],
'where'
=>
$searchWhere
,
'where'
=>
$searchWhere
,
'data'
=>
$searchData
,
'data'
=>
$searchData
,
'orderBy'
=>
[
'creation_date DESC'
],
'orderBy'
=>
[
'creation_date DESC'
]
'limit'
=>
$limit
,
'offset'
=>
$offset
]);
]);
if
(
empty
(
$allResources
[
$offset
]))
{
return
$response
->
withJson
([
'resources'
=>
[],
'count'
=>
0
]);
}
$resIds
=
[];
$order
=
'CASE res_id '
;
for
(
$i
=
$offset
;
$i
<
$limit
;
$i
++
)
{
if
(
empty
(
$allResources
[
$i
][
'resId'
]))
{
break
;
}
$order
.
=
"WHEN
{
$allResources
[
$i
][
'resId'
]
}
THEN
{
$i
}
"
;
$resIds
[]
=
$allResources
[
$i
][
'resId'
];
}
$order
.
=
'END'
;
$resources
=
ResModel
::
get
([
'select'
=>
[
'res_id as "resId"'
,
'category_id as "category"'
,
'alt_identifier as "chrono"'
,
'subject'
,
'barcode'
,
'filename'
,
'creation_date as "creationDate"'
,
'type_id as "type"'
,
'priority'
,
'status'
,
'dest_user as "destUser"'
,
'count(1) OVER()'
],
'where'
=>
[
'res_id in (?)'
],
'data'
=>
[
$resIds
],
'orderBy'
=>
[
$order
]
]);
if
(
empty
(
$resources
))
{
if
(
empty
(
$resources
))
{
return
$response
->
withJson
([]);
return
$response
->
withJson
([
'resources'
=>
[],
'count'
=>
0
]);
}
}
$resourcesIds
=
array_column
(
$resources
,
'resId'
);
$resourcesIds
=
array_column
(
$resources
,
'resId'
);
...
@@ -168,6 +187,9 @@ class SearchController
...
@@ -168,6 +187,9 @@ class SearchController
$statusesIds
=
array_column
(
$resources
,
'status'
);
$statusesIds
=
array_column
(
$resources
,
'status'
);
$statuses
=
StatusModel
::
get
([
'select'
=>
[
'id'
,
'label_status'
,
'img_filename'
],
'where'
=>
[
'id in (?)'
],
'data'
=>
[
$statusesIds
]]);
$statuses
=
StatusModel
::
get
([
'select'
=>
[
'id'
,
'label_status'
,
'img_filename'
],
'where'
=>
[
'id in (?)'
],
'data'
=>
[
$statusesIds
]]);
$doctypesIds
=
array_column
(
$resources
,
'type'
);
$doctypes
=
DoctypeModel
::
get
([
'select'
=>
[
'type_id'
,
'description'
],
'where'
=>
[
'type_id in (?)'
],
'data'
=>
[
$doctypesIds
]]);
$correspondents
=
ResourceContactModel
::
get
([
$correspondents
=
ResourceContactModel
::
get
([
'select'
=>
[
'item_id as id'
,
'type'
,
'mode'
,
'res_id'
],
'select'
=>
[
'item_id as id'
,
'type'
,
'mode'
,
'res_id'
],
'where'
=>
[
'res_id in (?)'
],
'where'
=>
[
'res_id in (?)'
],
...
@@ -190,6 +212,11 @@ class SearchController
...
@@ -190,6 +212,11 @@ class SearchController
}
}
}
}
}
}
foreach
(
$doctypes
as
$doctype
)
{
if
(
$doctype
[
'type_id'
]
==
$resource
[
'type'
])
{
$resources
[
$key
][
'typeLabel'
]
=
$doctype
[
'description'
];
}
}
if
(
!
empty
(
$resource
[
'destUser'
]))
{
if
(
!
empty
(
$resource
[
'destUser'
]))
{
$resources
[
$key
][
'destUserLabel'
]
=
UserModel
::
getLabelledUserById
([
'login'
=>
$resource
[
'destUser'
]]);
$resources
[
$key
][
'destUserLabel'
]
=
UserModel
::
getLabelledUserById
([
'login'
=>
$resource
[
'destUser'
]]);
}
}
...
@@ -212,6 +239,6 @@ class SearchController
...
@@ -212,6 +239,6 @@ class SearchController
}
}
}
}
return
$response
->
withJson
(
$resources
);
return
$response
->
withJson
(
[
'resources'
=>
$resources
,
'count'
=>
count
(
$allResources
)]
);
}
}
}
}
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