Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Essem
Sharkey
Commits
aff76a57
Commit
aff76a57
authored
7 years ago
by
こぴなたみぽ
Browse files
Options
Downloads
Patches
Plain Diff
✌️
parent
b2223c19
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/api/endpoints/posts/search.ts
+28
-3
28 additions, 3 deletions
src/api/endpoints/posts/search.ts
src/web/app/common/scripts/parse-search-query.ts
+3
-0
3 additions, 0 deletions
src/web/app/common/scripts/parse-search-query.ts
src/web/docs/search.ja.pug
+8
-0
8 additions, 0 deletions
src/web/docs/search.ja.pug
with
39 additions
and
3 deletions
src/api/endpoints/posts/search.ts
+
28
−
3
View file @
aff76a57
...
...
@@ -46,6 +46,10 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
const
[
media
=
null
,
mediaErr
]
=
$
(
params
.
media
).
optional
.
nullable
.
boolean
().
$
;
if
(
mediaErr
)
return
rej
(
'
invalid media param
'
);
// Get 'poll' parameter
const
[
poll
=
null
,
pollErr
]
=
$
(
params
.
poll
).
optional
.
nullable
.
boolean
().
$
;
if
(
pollErr
)
return
rej
(
'
invalid poll param
'
);
// Get 'since_date' parameter
const
[
sinceDate
,
sinceDateErr
]
=
$
(
params
.
since_date
).
optional
.
number
().
$
;
if
(
sinceDateErr
)
throw
'
invalid since_date param
'
;
...
...
@@ -76,11 +80,11 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// If Elasticsearch is available, search by it
// If not, search by MongoDB
(
config
.
elasticsearch
.
enable
?
byElasticsearch
:
byNative
)
(
res
,
rej
,
me
,
text
,
user
,
following
,
reply
,
repost
,
media
,
sinceDate
,
untilDate
,
offset
,
limit
);
(
res
,
rej
,
me
,
text
,
user
,
following
,
reply
,
repost
,
media
,
poll
,
sinceDate
,
untilDate
,
offset
,
limit
);
});
// Search by MongoDB
async
function
byNative
(
res
,
rej
,
me
,
text
,
userId
,
following
,
reply
,
repost
,
media
,
sinceDate
,
untilDate
,
offset
,
max
)
{
async
function
byNative
(
res
,
rej
,
me
,
text
,
userId
,
following
,
reply
,
repost
,
media
,
poll
,
sinceDate
,
untilDate
,
offset
,
max
)
{
const
q
:
any
=
{
$and
:
[]
};
...
...
@@ -175,6 +179,27 @@ async function byNative(res, rej, me, text, userId, following, reply, repost, me
}
}
if
(
poll
!=
null
)
{
if
(
poll
)
{
push
({
poll
:
{
$exists
:
true
,
$ne
:
null
}
});
}
else
{
push
({
$or
:
[{
poll
:
{
$exists
:
false
}
},
{
poll
:
null
}]
});
}
}
if
(
sinceDate
)
{
push
({
created_at
:
{
...
...
@@ -207,7 +232,7 @@ async function byNative(res, rej, me, text, userId, following, reply, repost, me
}
// Search by Elasticsearch
async
function
byElasticsearch
(
res
,
rej
,
me
,
text
,
userId
,
following
,
reply
,
repost
,
media
,
sinceDate
,
untilDate
,
offset
,
max
)
{
async
function
byElasticsearch
(
res
,
rej
,
me
,
text
,
userId
,
following
,
reply
,
repost
,
media
,
poll
,
sinceDate
,
untilDate
,
offset
,
max
)
{
const
es
=
require
(
'
../../db/elasticsearch
'
);
es
.
search
({
...
...
This diff is collapsed.
Click to expand it.
src/web/app/common/scripts/parse-search-query.ts
+
3
−
0
View file @
aff76a57
...
...
@@ -22,6 +22,9 @@ export default function(qs: string) {
case
'
media
'
:
q
[
'
media
'
]
=
value
==
'
null
'
?
null
:
value
==
'
true
'
;
break
;
case
'
poll
'
:
q
[
'
poll
'
]
=
value
==
'
null
'
?
null
:
value
==
'
true
'
;
break
;
case
'
until
'
:
case
'
since
'
:
// YYYY-MM-DD
...
...
This diff is collapsed.
Click to expand it.
src/web/docs/search.ja.pug
+
8
−
0
View file @
aff76a57
...
...
@@ -53,6 +53,14 @@ section
| false ... メディアが添付されていない投稿に限定。
br
| null ... 特に限定しない(デフォルト)
tr
td poll
td
| true ... 投票が添付されている投稿に限定。
br
| false ... 投票が添付されていない投稿に限定。
br
| null ... 特に限定しない(デフォルト)
tr
td until
td 上限の日時。(YYYY-MM-DD)
...
...
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