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
07667257
Commit
07667257
authored
Jul 31, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support order by time asc
parent
ea70dd85
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
9 deletions
+31
-9
memo_service.go
server/router/api/v1/memo_service.go
+8
-0
memo.go
store/db/mysql/memo.go
+7
-3
memo.go
store/db/postgres/memo.go
+7
-3
memo.go
store/db/sqlite/memo.go
+7
-3
memo.go
store/memo.go
+2
-0
No files found.
server/router/api/v1/memo_service.go
View file @
07667257
...
@@ -891,6 +891,9 @@ func (s *APIV1Service) buildMemoFindWithFilter(ctx context.Context, find *store.
...
@@ -891,6 +891,9 @@ func (s *APIV1Service) buildMemoFindWithFilter(ctx context.Context, find *store.
if
filter
.
OrderByPinned
{
if
filter
.
OrderByPinned
{
find
.
OrderByPinned
=
filter
.
OrderByPinned
find
.
OrderByPinned
=
filter
.
OrderByPinned
}
}
if
filter
.
OrderByTimeAsc
{
find
.
OrderByTimeAsc
=
filter
.
OrderByTimeAsc
}
if
filter
.
DisplayTimeAfter
!=
nil
{
if
filter
.
DisplayTimeAfter
!=
nil
{
workspaceMemoRelatedSetting
,
err
:=
s
.
Store
.
GetWorkspaceMemoRelatedSetting
(
ctx
)
workspaceMemoRelatedSetting
,
err
:=
s
.
Store
.
GetWorkspaceMemoRelatedSetting
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -995,6 +998,7 @@ var MemoFilterCELAttributes = []cel.EnvOption{
...
@@ -995,6 +998,7 @@ var MemoFilterCELAttributes = []cel.EnvOption{
cel
.
Variable
(
"visibilities"
,
cel
.
ListType
(
cel
.
StringType
)),
cel
.
Variable
(
"visibilities"
,
cel
.
ListType
(
cel
.
StringType
)),
cel
.
Variable
(
"tag_search"
,
cel
.
ListType
(
cel
.
StringType
)),
cel
.
Variable
(
"tag_search"
,
cel
.
ListType
(
cel
.
StringType
)),
cel
.
Variable
(
"order_by_pinned"
,
cel
.
BoolType
),
cel
.
Variable
(
"order_by_pinned"
,
cel
.
BoolType
),
cel
.
Variable
(
"order_by_time_asc"
,
cel
.
BoolType
),
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
(
"creator"
,
cel
.
StringType
),
cel
.
Variable
(
"creator"
,
cel
.
StringType
),
...
@@ -1014,6 +1018,7 @@ type MemoFilter struct {
...
@@ -1014,6 +1018,7 @@ type MemoFilter struct {
Visibilities
[]
store
.
Visibility
Visibilities
[]
store
.
Visibility
TagSearch
[]
string
TagSearch
[]
string
OrderByPinned
bool
OrderByPinned
bool
OrderByTimeAsc
bool
DisplayTimeBefore
*
int64
DisplayTimeBefore
*
int64
DisplayTimeAfter
*
int64
DisplayTimeAfter
*
int64
Creator
*
string
Creator
*
string
...
@@ -1074,6 +1079,9 @@ func findMemoField(callExpr *expr.Expr_Call, filter *MemoFilter) {
...
@@ -1074,6 +1079,9 @@ func findMemoField(callExpr *expr.Expr_Call, filter *MemoFilter) {
}
else
if
idExpr
.
Name
==
"order_by_pinned"
{
}
else
if
idExpr
.
Name
==
"order_by_pinned"
{
value
:=
callExpr
.
Args
[
1
]
.
GetConstExpr
()
.
GetBoolValue
()
value
:=
callExpr
.
Args
[
1
]
.
GetConstExpr
()
.
GetBoolValue
()
filter
.
OrderByPinned
=
value
filter
.
OrderByPinned
=
value
}
else
if
idExpr
.
Name
==
"order_by_time_asc"
{
value
:=
callExpr
.
Args
[
1
]
.
GetConstExpr
()
.
GetBoolValue
()
filter
.
OrderByTimeAsc
=
value
}
else
if
idExpr
.
Name
==
"display_time_before"
{
}
else
if
idExpr
.
Name
==
"display_time_before"
{
displayTimeBefore
:=
callExpr
.
Args
[
1
]
.
GetConstExpr
()
.
GetInt64Value
()
displayTimeBefore
:=
callExpr
.
Args
[
1
]
.
GetConstExpr
()
.
GetInt64Value
()
filter
.
DisplayTimeBefore
=
&
displayTimeBefore
filter
.
DisplayTimeBefore
=
&
displayTimeBefore
...
...
store/db/mysql/memo.go
View file @
07667257
...
@@ -116,12 +116,16 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -116,12 +116,16 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
find
.
OrderByPinned
{
if
find
.
OrderByPinned
{
orders
=
append
(
orders
,
"`pinned` DESC"
)
orders
=
append
(
orders
,
"`pinned` DESC"
)
}
}
order
:=
"DESC"
if
find
.
OrderByTimeAsc
{
order
=
"ASC"
}
if
find
.
OrderByUpdatedTs
{
if
find
.
OrderByUpdatedTs
{
orders
=
append
(
orders
,
"`updated_ts`
DESC"
)
orders
=
append
(
orders
,
"`updated_ts`
"
+
order
)
}
else
{
}
else
{
orders
=
append
(
orders
,
"`created_ts`
DESC"
)
orders
=
append
(
orders
,
"`created_ts`
"
+
order
)
}
}
orders
=
append
(
orders
,
"`id`
DESC"
)
orders
=
append
(
orders
,
"`id`
"
+
order
)
if
find
.
Random
{
if
find
.
Random
{
orders
=
append
(
orders
,
"RAND()"
)
orders
=
append
(
orders
,
"RAND()"
)
}
}
...
...
store/db/postgres/memo.go
View file @
07667257
...
@@ -107,12 +107,16 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -107,12 +107,16 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
find
.
OrderByPinned
{
if
find
.
OrderByPinned
{
orders
=
append
(
orders
,
"pinned DESC"
)
orders
=
append
(
orders
,
"pinned DESC"
)
}
}
order
:=
"DESC"
if
find
.
OrderByTimeAsc
{
order
=
"ASC"
}
if
find
.
OrderByUpdatedTs
{
if
find
.
OrderByUpdatedTs
{
orders
=
append
(
orders
,
"updated_ts
DESC"
)
orders
=
append
(
orders
,
"updated_ts
"
+
order
)
}
else
{
}
else
{
orders
=
append
(
orders
,
"created_ts
DESC"
)
orders
=
append
(
orders
,
"created_ts
"
+
order
)
}
}
orders
=
append
(
orders
,
"id
DESC"
)
orders
=
append
(
orders
,
"id
"
+
order
)
if
find
.
Random
{
if
find
.
Random
{
orders
=
append
(
orders
,
"RAND()"
)
orders
=
append
(
orders
,
"RAND()"
)
}
}
...
...
store/db/sqlite/memo.go
View file @
07667257
...
@@ -108,12 +108,16 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
...
@@ -108,12 +108,16 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
find
.
OrderByPinned
{
if
find
.
OrderByPinned
{
orderBy
=
append
(
orderBy
,
"`pinned` DESC"
)
orderBy
=
append
(
orderBy
,
"`pinned` DESC"
)
}
}
order
:=
"DESC"
if
find
.
OrderByTimeAsc
{
order
=
"ASC"
}
if
find
.
OrderByUpdatedTs
{
if
find
.
OrderByUpdatedTs
{
orderBy
=
append
(
orderBy
,
"`updated_ts`
DESC"
)
orderBy
=
append
(
orderBy
,
"`updated_ts`
"
+
order
)
}
else
{
}
else
{
orderBy
=
append
(
orderBy
,
"`created_ts`
DESC"
)
orderBy
=
append
(
orderBy
,
"`created_ts`
"
+
order
)
}
}
orderBy
=
append
(
orderBy
,
"`id`
DESC"
)
orderBy
=
append
(
orderBy
,
"`id`
"
+
order
)
if
find
.
Random
{
if
find
.
Random
{
orderBy
=
[]
string
{
"RANDOM()"
}
orderBy
=
[]
string
{
"RANDOM()"
}
}
}
...
...
store/memo.go
View file @
07667257
...
@@ -80,6 +80,8 @@ type FindMemo struct {
...
@@ -80,6 +80,8 @@ type FindMemo struct {
Offset
*
int
Offset
*
int
OrderByUpdatedTs
bool
OrderByUpdatedTs
bool
OrderByPinned
bool
OrderByPinned
bool
OrderByTimeAsc
bool
}
}
type
FindMemoPayload
struct
{
type
FindMemoPayload
struct
{
...
...
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