Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
6d9770b9
Commit
6d9770b9
authored
Jul 21, 2025
by
johnnyjoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: move filter to filters
parent
7481fe10
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
71 deletions
+61
-71
memo_service.go
server/router/api/v1/memo_service.go
+3
-8
user_service_stats.go
server/router/api/v1/user_service_stats.go
+2
-7
memo.go
store/db/mysql/memo.go
+18
-18
memo.go
store/db/postgres/memo.go
+19
-19
memo.go
store/db/sqlite/memo.go
+18
-18
memo.go
store/memo.go
+1
-1
No files found.
server/router/api/v1/memo_service.go
View file @
6d9770b9
...
@@ -135,7 +135,7 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq
...
@@ -135,7 +135,7 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq
if
err
:=
s
.
validateFilter
(
ctx
,
request
.
Filter
);
err
!=
nil
{
if
err
:=
s
.
validateFilter
(
ctx
,
request
.
Filter
);
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"invalid filter: %v"
,
err
)
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"invalid filter: %v"
,
err
)
}
}
memoFind
.
Filter
=
&
request
.
Filter
memoFind
.
Filter
s
=
append
(
memoFind
.
Filters
,
request
.
Filter
)
}
}
currentUser
,
err
:=
s
.
GetCurrentUser
(
ctx
)
currentUser
,
err
:=
s
.
GetCurrentUser
(
ctx
)
...
@@ -146,13 +146,8 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq
...
@@ -146,13 +146,8 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
}
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
}
}
else
{
}
else
{
if
memoFind
.
CreatorID
==
nil
{
if
memoFind
.
CreatorID
==
nil
{
internalFilter
:=
fmt
.
Sprintf
(
`creator_id == %d || visibility in ["PUBLIC", "PROTECTED"]`
,
currentUser
.
ID
)
filter
:=
fmt
.
Sprintf
(
`creator_id == %d || visibility in ["PUBLIC", "PROTECTED"]`
,
currentUser
.
ID
)
if
memoFind
.
Filter
!=
nil
{
memoFind
.
Filters
=
append
(
memoFind
.
Filters
,
filter
)
filter
:=
fmt
.
Sprintf
(
"(%s) && (%s)"
,
*
memoFind
.
Filter
,
internalFilter
)
memoFind
.
Filter
=
&
filter
}
else
{
memoFind
.
Filter
=
&
internalFilter
}
}
else
if
*
memoFind
.
CreatorID
!=
currentUser
.
ID
{
}
else
if
*
memoFind
.
CreatorID
!=
currentUser
.
ID
{
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
,
store
.
Protected
}
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
,
store
.
Protected
}
}
}
...
...
server/router/api/v1/user_service_stats.go
View file @
6d9770b9
...
@@ -36,13 +36,8 @@ func (s *APIV1Service) ListAllUserStats(ctx context.Context, _ *v1pb.ListAllUser
...
@@ -36,13 +36,8 @@ func (s *APIV1Service) ListAllUserStats(ctx context.Context, _ *v1pb.ListAllUser
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
}
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
}
}
else
{
}
else
{
if
memoFind
.
CreatorID
==
nil
{
if
memoFind
.
CreatorID
==
nil
{
internalFilter
:=
fmt
.
Sprintf
(
`creator_id == %d || visibility in ["PUBLIC", "PROTECTED"]`
,
currentUser
.
ID
)
filter
:=
fmt
.
Sprintf
(
`creator_id == %d || visibility in ["PUBLIC", "PROTECTED"]`
,
currentUser
.
ID
)
if
memoFind
.
Filter
!=
nil
{
memoFind
.
Filters
=
append
(
memoFind
.
Filters
,
filter
)
filter
:=
fmt
.
Sprintf
(
"(%s) && (%s)"
,
*
memoFind
.
Filter
,
internalFilter
)
memoFind
.
Filter
=
&
filter
}
else
{
memoFind
.
Filter
=
&
internalFilter
}
}
else
if
*
memoFind
.
CreatorID
!=
currentUser
.
ID
{
}
else
if
*
memoFind
.
CreatorID
!=
currentUser
.
ID
{
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
,
store
.
Protected
}
memoFind
.
VisibilityList
=
[]
store
.
Visibility
{
store
.
Public
,
store
.
Protected
}
}
}
...
...
store/db/mysql/memo.go
View file @
6d9770b9
...
@@ -50,6 +50,24 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
...
@@ -50,6 +50,24 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
func
(
d
*
DB
)
ListMemos
(
ctx
context
.
Context
,
find
*
store
.
FindMemo
)
([]
*
store
.
Memo
,
error
)
{
func
(
d
*
DB
)
ListMemos
(
ctx
context
.
Context
,
find
*
store
.
FindMemo
)
([]
*
store
.
Memo
,
error
)
{
where
,
having
,
args
:=
[]
string
{
"1 = 1"
},
[]
string
{
"1 = 1"
},
[]
any
{}
where
,
having
,
args
:=
[]
string
{
"1 = 1"
},
[]
string
{
"1 = 1"
},
[]
any
{}
for
_
,
filterStr
:=
range
find
.
Filters
{
// Parse filter string and return the parsed expression.
// The filter string should be a CEL expression.
parsedExpr
,
err
:=
filter
.
Parse
(
filterStr
,
filter
.
MemoFilterCELAttributes
...
)
if
err
!=
nil
{
return
nil
,
err
}
convertCtx
:=
filter
.
NewConvertContext
()
// ConvertExprToSQL converts the parsed expression to a SQL condition string.
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
return
nil
,
err
}
condition
:=
convertCtx
.
Buffer
.
String
()
if
condition
!=
""
{
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
condition
))
args
=
append
(
args
,
convertCtx
.
Args
...
)
}
}
if
v
:=
find
.
ID
;
v
!=
nil
{
if
v
:=
find
.
ID
;
v
!=
nil
{
where
,
args
=
append
(
where
,
"`memo`.`id` = ?"
),
append
(
args
,
*
v
)
where
,
args
=
append
(
where
,
"`memo`.`id` = ?"
),
append
(
args
,
*
v
)
}
}
...
@@ -112,24 +130,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -112,24 +130,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
where
=
append
(
where
,
"JSON_EXTRACT(`memo`.`payload`, '$.property.hasIncompleteTasks') IS TRUE"
)
where
=
append
(
where
,
"JSON_EXTRACT(`memo`.`payload`, '$.property.hasIncompleteTasks') IS TRUE"
)
}
}
}
}
if
v
:=
find
.
Filter
;
v
!=
nil
{
// Parse filter string and return the parsed expression.
// The filter string should be a CEL expression.
parsedExpr
,
err
:=
filter
.
Parse
(
*
v
,
filter
.
MemoFilterCELAttributes
...
)
if
err
!=
nil
{
return
nil
,
err
}
convertCtx
:=
filter
.
NewConvertContext
()
// ConvertExprToSQL converts the parsed expression to a SQL condition string.
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
return
nil
,
err
}
condition
:=
convertCtx
.
Buffer
.
String
()
if
condition
!=
""
{
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
condition
))
args
=
append
(
args
,
convertCtx
.
Args
...
)
}
}
if
find
.
ExcludeComments
{
if
find
.
ExcludeComments
{
having
=
append
(
having
,
"`parent_id` IS NULL"
)
having
=
append
(
having
,
"`parent_id` IS NULL"
)
}
}
...
...
store/db/postgres/memo.go
View file @
6d9770b9
...
@@ -41,6 +41,25 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
...
@@ -41,6 +41,25 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
func
(
d
*
DB
)
ListMemos
(
ctx
context
.
Context
,
find
*
store
.
FindMemo
)
([]
*
store
.
Memo
,
error
)
{
func
(
d
*
DB
)
ListMemos
(
ctx
context
.
Context
,
find
*
store
.
FindMemo
)
([]
*
store
.
Memo
,
error
)
{
where
,
args
:=
[]
string
{
"1 = 1"
},
[]
any
{}
where
,
args
:=
[]
string
{
"1 = 1"
},
[]
any
{}
for
_
,
filterStr
:=
range
find
.
Filters
{
// Parse filter string and return the parsed expression.
// The filter string should be a CEL expression.
parsedExpr
,
err
:=
filter
.
Parse
(
filterStr
,
filter
.
MemoFilterCELAttributes
...
)
if
err
!=
nil
{
return
nil
,
err
}
convertCtx
:=
filter
.
NewConvertContext
()
convertCtx
.
ArgsOffset
=
len
(
args
)
// ConvertExprToSQL converts the parsed expression to a SQL condition string.
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
return
nil
,
err
}
condition
:=
convertCtx
.
Buffer
.
String
()
if
condition
!=
""
{
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
condition
))
args
=
append
(
args
,
convertCtx
.
Args
...
)
}
}
if
v
:=
find
.
ID
;
v
!=
nil
{
if
v
:=
find
.
ID
;
v
!=
nil
{
where
,
args
=
append
(
where
,
"memo.id = "
+
placeholder
(
len
(
args
)
+
1
)),
append
(
args
,
*
v
)
where
,
args
=
append
(
where
,
"memo.id = "
+
placeholder
(
len
(
args
)
+
1
)),
append
(
args
,
*
v
)
}
}
...
@@ -103,25 +122,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -103,25 +122,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
where
=
append
(
where
,
"(memo.payload->'property'->>'hasIncompleteTasks')::BOOLEAN IS TRUE"
)
where
=
append
(
where
,
"(memo.payload->'property'->>'hasIncompleteTasks')::BOOLEAN IS TRUE"
)
}
}
}
}
if
v
:=
find
.
Filter
;
v
!=
nil
{
// Parse filter string and return the parsed expression.
// The filter string should be a CEL expression.
parsedExpr
,
err
:=
filter
.
Parse
(
*
v
,
filter
.
MemoFilterCELAttributes
...
)
if
err
!=
nil
{
return
nil
,
err
}
convertCtx
:=
filter
.
NewConvertContext
()
convertCtx
.
ArgsOffset
=
len
(
args
)
// ConvertExprToSQL converts the parsed expression to a SQL condition string.
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
return
nil
,
err
}
condition
:=
convertCtx
.
Buffer
.
String
()
if
condition
!=
""
{
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
condition
))
args
=
append
(
args
,
convertCtx
.
Args
...
)
}
}
if
find
.
ExcludeComments
{
if
find
.
ExcludeComments
{
where
=
append
(
where
,
"memo_relation.related_memo_id IS NULL"
)
where
=
append
(
where
,
"memo_relation.related_memo_id IS NULL"
)
}
}
...
...
store/db/sqlite/memo.go
View file @
6d9770b9
...
@@ -42,6 +42,24 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
...
@@ -42,6 +42,24 @@ func (d *DB) CreateMemo(ctx context.Context, create *store.Memo) (*store.Memo, e
func
(
d
*
DB
)
ListMemos
(
ctx
context
.
Context
,
find
*
store
.
FindMemo
)
([]
*
store
.
Memo
,
error
)
{
func
(
d
*
DB
)
ListMemos
(
ctx
context
.
Context
,
find
*
store
.
FindMemo
)
([]
*
store
.
Memo
,
error
)
{
where
,
args
:=
[]
string
{
"1 = 1"
},
[]
any
{}
where
,
args
:=
[]
string
{
"1 = 1"
},
[]
any
{}
for
_
,
filterStr
:=
range
find
.
Filters
{
// Parse filter string and return the parsed expression.
// The filter string should be a CEL expression.
parsedExpr
,
err
:=
filter
.
Parse
(
filterStr
,
filter
.
MemoFilterCELAttributes
...
)
if
err
!=
nil
{
return
nil
,
err
}
convertCtx
:=
filter
.
NewConvertContext
()
// ConvertExprToSQL converts the parsed expression to a SQL condition string.
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
return
nil
,
err
}
condition
:=
convertCtx
.
Buffer
.
String
()
if
condition
!=
""
{
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
condition
))
args
=
append
(
args
,
convertCtx
.
Args
...
)
}
}
if
v
:=
find
.
ID
;
v
!=
nil
{
if
v
:=
find
.
ID
;
v
!=
nil
{
where
,
args
=
append
(
where
,
"`memo`.`id` = ?"
),
append
(
args
,
*
v
)
where
,
args
=
append
(
where
,
"`memo`.`id` = ?"
),
append
(
args
,
*
v
)
}
}
...
@@ -104,24 +122,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -104,24 +122,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
where
=
append
(
where
,
"JSON_EXTRACT(`memo`.`payload`, '$.property.hasIncompleteTasks') IS TRUE"
)
where
=
append
(
where
,
"JSON_EXTRACT(`memo`.`payload`, '$.property.hasIncompleteTasks') IS TRUE"
)
}
}
}
}
if
v
:=
find
.
Filter
;
v
!=
nil
{
// Parse filter string and return the parsed expression.
// The filter string should be a CEL expression.
parsedExpr
,
err
:=
filter
.
Parse
(
*
v
,
filter
.
MemoFilterCELAttributes
...
)
if
err
!=
nil
{
return
nil
,
err
}
convertCtx
:=
filter
.
NewConvertContext
()
// ConvertExprToSQL converts the parsed expression to a SQL condition string.
if
err
:=
d
.
ConvertExprToSQL
(
convertCtx
,
parsedExpr
.
GetExpr
());
err
!=
nil
{
return
nil
,
err
}
condition
:=
convertCtx
.
Buffer
.
String
()
if
condition
!=
""
{
where
=
append
(
where
,
fmt
.
Sprintf
(
"(%s)"
,
condition
))
args
=
append
(
args
,
convertCtx
.
Args
...
)
}
}
if
find
.
ExcludeComments
{
if
find
.
ExcludeComments
{
where
=
append
(
where
,
"`parent_id` IS NULL"
)
where
=
append
(
where
,
"`parent_id` IS NULL"
)
}
}
...
...
store/memo.go
View file @
6d9770b9
...
@@ -74,7 +74,7 @@ type FindMemo struct {
...
@@ -74,7 +74,7 @@ type FindMemo struct {
PayloadFind
*
FindMemoPayload
PayloadFind
*
FindMemoPayload
ExcludeContent
bool
ExcludeContent
bool
ExcludeComments
bool
ExcludeComments
bool
Filter
*
string
Filter
s
[]
string
// Pagination
// Pagination
Limit
*
int
Limit
*
int
...
...
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