Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
a6b1f93d
Commit
a6b1f93d
authored
Aug 13, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize: invokeFts
parent
5e0baeb2
Pipeline
#23055
passed with stages
in 13 minutes and 46 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
23 deletions
+13
-23
src/middleware/sqlite/fts.ts
src/middleware/sqlite/fts.ts
+13
-23
No files found.
src/middleware/sqlite/fts.ts
View file @
a6b1f93d
...
...
@@ -23,34 +23,24 @@ export interface FtsParams {
export
function
invokeFts
(
db
:
Database
,
params
:
FtsParams
):
CardMeta
[]
{
const
{
query
,
conditions
}
=
params
;
const
ftsTexts
:
CardText
[]
=
[];
const
ftsMetas
:
CardMeta
[]
=
[];
const
filterConditions
=
getFtsCondtions
(
conditions
);
const
textStmt
=
db
.
prepare
(
`SELECT * FROM texts INNER JOIN datas ON texts.id = datas.id
${
filterConditions
==
""
?
"
WHERE name LIKE $query
"
:
`WHERE name LIKE $query AND
${
filterConditions
}
`
}
`
);
textStmt
.
bind
({
$query
:
`%
${
query
}
%`
}
);
const
stmt
=
db
.
prepare
(
`
SELECT datas.*, texts.*
FROM datas
INNER JOIN texts ON datas.id = texts.id
WHERE texts.name LIKE $query
${
filterConditions
?
`AND
${
filterConditions
}
`
:
""
}
`
);
while
(
textStmt
.
step
())
{
const
row
=
textStmt
.
getAsObject
();
ftsTexts
.
push
(
row
);
}
stmt
.
bind
({
$query
:
`%
${
query
}
%`
});
for
(
const
text
of
ftsTexts
)
{
const
id
=
text
.
id
;
if
(
id
)
{
const
sql
=
"
SELECT * FROM datas WHERE ID = $id
"
;
const
dataStmt
=
db
.
prepare
(
sql
);
const
data
:
CardData
=
dataStmt
.
getAsObject
({
$id
:
id
});
if
(
Object
.
values
(
data
).
filter
((
v
)
=>
v
!==
undefined
).
length
>
0
)
{
ftsMetas
.
push
(
constructCardMeta
(
id
,
data
,
text
));
}
}
while
(
stmt
.
step
())
{
const
row
=
stmt
.
getAsObject
()
as
CardData
&
CardText
;
ftsMetas
.
push
(
constructCardMeta
(
row
.
id
!
,
row
,
row
));
}
return
ftsMetas
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment