mirror of
https://github.com/usememos/memos.git
synced 2025-04-03 20:31:10 +02:00
chore: move part of memo filter
This commit is contained in:
parent
fafd6d81c7
commit
81e8aed6ab
@ -134,6 +134,14 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq
|
|||||||
memoFind.VisibilityList = []store.Visibility{store.Public, store.Protected}
|
memoFind.VisibilityList = []store.Visibility{store.Public, store.Protected}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
workspaceMemoRelatedSetting, err := s.Store.GetWorkspaceMemoRelatedSetting(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get workspace memo related setting")
|
||||||
|
}
|
||||||
|
if workspaceMemoRelatedSetting.DisplayWithUpdateTime {
|
||||||
|
memoFind.OrderByUpdatedTs = true
|
||||||
|
}
|
||||||
|
|
||||||
var limit, offset int
|
var limit, offset int
|
||||||
if request.PageToken != "" {
|
if request.PageToken != "" {
|
||||||
var pageToken v1pb.PageToken
|
var pageToken v1pb.PageToken
|
||||||
|
@ -52,9 +52,6 @@ func (s *APIV1Service) buildMemoFindWithFilter(ctx context.Context, find *store.
|
|||||||
find.CreatedTsBefore = filterExpr.DisplayTimeBefore
|
find.CreatedTsBefore = filterExpr.DisplayTimeBefore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if filterExpr.IncludeComments {
|
|
||||||
find.ExcludeComments = false
|
|
||||||
}
|
|
||||||
if filterExpr.HasLink {
|
if filterExpr.HasLink {
|
||||||
find.PayloadFind.HasLink = true
|
find.PayloadFind.HasLink = true
|
||||||
}
|
}
|
||||||
@ -68,14 +65,6 @@ func (s *APIV1Service) buildMemoFindWithFilter(ctx context.Context, find *store.
|
|||||||
find.PayloadFind.HasIncompleteTasks = true
|
find.PayloadFind.HasIncompleteTasks = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
workspaceMemoRelatedSetting, err := s.Store.GetWorkspaceMemoRelatedSetting(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return status.Errorf(codes.Internal, "failed to get workspace memo related setting")
|
|
||||||
}
|
|
||||||
if workspaceMemoRelatedSetting.DisplayWithUpdateTime {
|
|
||||||
find.OrderByUpdatedTs = true
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +74,6 @@ var MemoFilterCELAttributes = []cel.EnvOption{
|
|||||||
cel.Variable("tag_search", cel.ListType(cel.StringType)),
|
cel.Variable("tag_search", cel.ListType(cel.StringType)),
|
||||||
cel.Variable("display_time_before", cel.IntType),
|
cel.Variable("display_time_before", cel.IntType),
|
||||||
cel.Variable("display_time_after", cel.IntType),
|
cel.Variable("display_time_after", cel.IntType),
|
||||||
cel.Variable("include_comments", cel.BoolType),
|
|
||||||
cel.Variable("has_link", cel.BoolType),
|
cel.Variable("has_link", cel.BoolType),
|
||||||
cel.Variable("has_task_list", cel.BoolType),
|
cel.Variable("has_task_list", cel.BoolType),
|
||||||
cel.Variable("has_code", cel.BoolType),
|
cel.Variable("has_code", cel.BoolType),
|
||||||
@ -97,7 +85,6 @@ type MemoFilter struct {
|
|||||||
TagSearch []string
|
TagSearch []string
|
||||||
DisplayTimeBefore *int64
|
DisplayTimeBefore *int64
|
||||||
DisplayTimeAfter *int64
|
DisplayTimeAfter *int64
|
||||||
IncludeComments bool
|
|
||||||
HasLink bool
|
HasLink bool
|
||||||
HasTaskList bool
|
HasTaskList bool
|
||||||
HasCode bool
|
HasCode bool
|
||||||
@ -147,9 +134,6 @@ func findMemoField(callExpr *exprv1.Expr_Call, filter *MemoFilter) {
|
|||||||
} else if idExpr.Name == "display_time_after" {
|
} else if idExpr.Name == "display_time_after" {
|
||||||
displayTimeAfter := callExpr.Args[1].GetConstExpr().GetInt64Value()
|
displayTimeAfter := callExpr.Args[1].GetConstExpr().GetInt64Value()
|
||||||
filter.DisplayTimeAfter = &displayTimeAfter
|
filter.DisplayTimeAfter = &displayTimeAfter
|
||||||
} else if idExpr.Name == "include_comments" {
|
|
||||||
value := callExpr.Args[1].GetConstExpr().GetBoolValue()
|
|
||||||
filter.IncludeComments = value
|
|
||||||
} else if idExpr.Name == "has_link" {
|
} else if idExpr.Name == "has_link" {
|
||||||
value := callExpr.Args[1].GetConstExpr().GetBoolValue()
|
value := callExpr.Args[1].GetConstExpr().GetBoolValue()
|
||||||
filter.HasLink = value
|
filter.HasLink = value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user