Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
6f61ee5f
Commit
6f61ee5f
authored
9 years ago
by
Mateus Rambo Strey
Browse files
Options
Downloads
Patches
Plain Diff
fix search order by most recent and search collection privacy
parent
0c31da69
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/services/search_service.rb
+6
-8
6 additions, 8 deletions
app/services/search_service.rb
app/views/search/index.html.erb
+2
-2
2 additions, 2 deletions
app/views/search/index.html.erb
with
8 additions
and
10 deletions
app/services/search_service.rb
+
6
−
8
View file @
6f61ee5f
...
...
@@ -19,9 +19,7 @@ class SearchService
def
build_search_query
(
params
=
{})
order
=
order_by
(
params
[
:order
])
ord_attr
=
order
ord_attr
.
slice!
(
' ASC'
)
ord_attr
.
slice!
(
' DESC'
)
ord_attr
=
order
.
split
(
' '
,
2
).
first
"SELECT @rid.asString(), last_modified, @class,
#{
ord_attr
}
FROM ("
+
main_query
(
params
)
+
") ORDER BY
#{
order
}
"
end
...
...
@@ -30,11 +28,11 @@ class SearchService
end
def
collection_query
(
params
=
{})
qry
=
"SELECT *, created_at as published_at, out('BelongsTo')[0].name as author FROM Collection"
qry
+=
"
WHERE
name LUCENE '
#{
params
[
:query
]
}
' OR description LUCENE '
#{
params
[
:query
]
}
'"
unless
params
[
:query
].
blank?
qry
=
"SELECT *, created_at as published_at, out('BelongsTo')[0].name as author FROM Collection
WHERE privacy = 'public'
"
qry
+=
"
AND (
name LUCENE '
#{
params
[
:query
]
}
' OR description LUCENE '
#{
params
[
:query
]
}
'
)
"
unless
params
[
:query
].
blank?
qry_filter
=
params
[
:query
].
blank?
?
" WHERE "
:
" AND "
filter
=
collection_learning_objects_filter
(
params
)
qry
+=
qry_filter
+
filter
unless
filter
.
blank?
qry
+=
" AND "
+
filter
unless
filter
.
blank?
qry
end
...
...
@@ -88,7 +86,7 @@ class SearchService
end
qry
end
def
order_by
(
order
)
case
order
when
'author'
...
...
@@ -125,4 +123,4 @@ class SearchService
cache_key
end
end
\ No newline at end of file
end
This diff is collapsed.
Click to expand it.
app/views/search/index.html.erb
+
2
−
2
View file @
6f61ee5f
...
...
@@ -55,8 +55,8 @@
<select
class=
"order sort-dropdown"
name=
"order"
>
<option
value=
""
>
relevância
</option>
<option
value=
"author"
>
autor
</option>
<option
value=
"publication
a
sc"
>
mais recente
</option>
<!-- <option value="publication
de
sc">mais velhos</option> -->
<option
value=
"publication
de
sc"
>
mais recente
</option>
<!-- <option value="publication
a
sc">mais velhos</option> -->
<option
value=
"title"
>
título
</option>
</select>
</form>
...
...
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