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
34ab8834
Commit
34ab8834
authored
Mar 13, 2025
by
Johnny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: sort by pinned
parent
d794e6db
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
15 deletions
+25
-15
memo_service.go
server/router/api/v1/memo_service.go
+1
-0
memo.go
store/db/mysql/memo.go
+7
-5
memo.go
store/db/postgres/memo.go
+7
-5
memo.go
store/db/sqlite/memo.go
+3
-1
memo.go
store/memo.go
+1
-0
MemoFilters.tsx
web/src/components/MemoFilters.tsx
+2
-2
StatisticsView.tsx
web/src/components/StatisticsView.tsx
+2
-2
Home.tsx
web/src/pages/Home.tsx
+1
-0
UserProfile.tsx
web/src/pages/UserProfile.tsx
+1
-0
No files found.
server/router/api/v1/memo_service.go
View file @
34ab8834
...
...
@@ -108,6 +108,7 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq
return
nil
,
status
.
Errorf
(
codes
.
InvalidArgument
,
"invalid parent: %v"
,
err
)
}
memoFind
.
CreatorID
=
&
userID
memoFind
.
OrderByPinned
=
true
}
if
request
.
State
==
v1pb
.
State_ARCHIVED
{
state
:=
store
.
Archived
...
...
store/db/mysql/memo.go
View file @
34ab8834
...
...
@@ -138,13 +138,15 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
find
.
OrderByTimeAsc
{
order
=
"ASC"
}
orders
:=
[]
string
{}
orderBy
:=
[]
string
{}
if
find
.
OrderByPinned
{
orderBy
=
append
(
orderBy
,
"`pinned` DESC"
)
}
if
find
.
OrderByUpdatedTs
{
order
s
=
append
(
orders
,
"`updated_ts` "
+
order
)
order
By
=
append
(
orderBy
,
"`updated_ts` "
+
order
)
}
else
{
order
s
=
append
(
orders
,
"`created_ts` "
+
order
)
order
By
=
append
(
orderBy
,
"`created_ts` "
+
order
)
}
orders
=
append
(
orders
,
"`id` "
+
order
)
fields
:=
[]
string
{
"`memo`.`id` AS `id`"
,
"`memo`.`uid` AS `uid`"
,
...
...
@@ -165,7 +167,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
"LEFT JOIN `memo_relation` ON `memo`.`id` = `memo_relation`.`memo_id` AND `memo_relation`.`type` = 'COMMENT'"
+
" "
+
"WHERE "
+
strings
.
Join
(
where
,
" AND "
)
+
" "
+
"HAVING "
+
strings
.
Join
(
having
,
" AND "
)
+
" "
+
"ORDER BY "
+
strings
.
Join
(
order
s
,
", "
)
"ORDER BY "
+
strings
.
Join
(
order
By
,
", "
)
if
find
.
Limit
!=
nil
{
query
=
fmt
.
Sprintf
(
"%s LIMIT %d"
,
query
,
*
find
.
Limit
)
if
find
.
Offset
!=
nil
{
...
...
store/db/postgres/memo.go
View file @
34ab8834
...
...
@@ -130,13 +130,15 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
if
find
.
OrderByTimeAsc
{
order
=
"ASC"
}
orders
:=
[]
string
{}
orderBy
:=
[]
string
{}
if
find
.
OrderByPinned
{
orderBy
=
append
(
orderBy
,
"pinned DESC"
)
}
if
find
.
OrderByUpdatedTs
{
order
s
=
append
(
orders
,
"updated_ts "
+
order
)
order
By
=
append
(
orderBy
,
"updated_ts "
+
order
)
}
else
{
order
s
=
append
(
orders
,
"created_ts "
+
order
)
order
By
=
append
(
orderBy
,
"created_ts "
+
order
)
}
orders
=
append
(
orders
,
"id "
+
order
)
fields
:=
[]
string
{
`memo.id AS id`
,
`memo.uid AS uid`
,
...
...
@@ -157,7 +159,7 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
FROM memo
LEFT JOIN memo_relation ON memo.id = memo_relation.memo_id AND memo_relation.type = 'COMMENT'
WHERE `
+
strings
.
Join
(
where
,
" AND "
)
+
`
ORDER BY `
+
strings
.
Join
(
order
s
,
", "
)
ORDER BY `
+
strings
.
Join
(
order
By
,
", "
)
if
find
.
Limit
!=
nil
{
query
=
fmt
.
Sprintf
(
"%s LIMIT %d"
,
query
,
*
find
.
Limit
)
if
find
.
Offset
!=
nil
{
...
...
store/db/sqlite/memo.go
View file @
34ab8834
...
...
@@ -131,12 +131,14 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
order
=
"ASC"
}
orderBy
:=
[]
string
{}
if
find
.
OrderByPinned
{
orderBy
=
append
(
orderBy
,
"`pinned` DESC"
)
}
if
find
.
OrderByUpdatedTs
{
orderBy
=
append
(
orderBy
,
"`updated_ts` "
+
order
)
}
else
{
orderBy
=
append
(
orderBy
,
"`created_ts` "
+
order
)
}
orderBy
=
append
(
orderBy
,
"`id` "
+
order
)
fields
:=
[]
string
{
"`memo`.`id` AS `id`"
,
"`memo`.`uid` AS `uid`"
,
...
...
store/memo.go
View file @
34ab8834
...
...
@@ -82,6 +82,7 @@ type FindMemo struct {
// Ordering
OrderByUpdatedTs
bool
OrderByPinned
bool
OrderByTimeAsc
bool
}
...
...
web/src/components/MemoFilters.tsx
View file @
34ab8834
import
{
isEqual
}
from
"lodash-es"
;
import
{
CalendarIcon
,
CheckCircleIcon
,
CodeIcon
,
EyeIcon
,
HashIcon
,
LinkIcon
,
Pin
Icon
,
SearchIcon
,
XIcon
}
from
"lucide-react"
;
import
{
CalendarIcon
,
CheckCircleIcon
,
CodeIcon
,
EyeIcon
,
HashIcon
,
LinkIcon
,
Bookmark
Icon
,
SearchIcon
,
XIcon
}
from
"lucide-react"
;
import
{
useEffect
}
from
"react"
;
import
{
useSearchParams
}
from
"react-router-dom"
;
import
{
FilterFactor
,
getMemoFilterKey
,
MemoFilter
,
stringifyFilters
,
useMemoFilterStore
}
from
"@/store/v1"
;
...
...
@@ -68,7 +68,7 @@ const FactorIcon = ({ factor, className }: { factor: FilterFactor; className?: s
visibility
:
<
EyeIcon
className=
{
className
}
/>,
contentSearch
:
<
SearchIcon
className=
{
className
}
/>,
displayTime
:
<
CalendarIcon
className=
{
className
}
/>,
pinned
:
<
Pin
Icon
className=
{
className
}
/>,
pinned
:
<
Bookmark
Icon
className=
{
className
}
/>,
"property.hasLink"
:
<
LinkIcon
className
=
{
className
}
/>
,
"property.hasTaskList"
:
<
CheckCircleIcon
className
=
{
className
}
/>
,
"property.hasCode"
:
<
CodeIcon
className
=
{
className
}
/>
,
...
...
web/src/components/StatisticsView.tsx
View file @
34ab8834
import
{
Tooltip
}
from
"@mui/joy"
;
import
dayjs
from
"dayjs"
;
import
{
countBy
}
from
"lodash-es"
;
import
{
CheckCircleIcon
,
ChevronRightIcon
,
ChevronLeftIcon
,
Code2Icon
,
LinkIcon
,
ListTodoIcon
,
Pin
Icon
}
from
"lucide-react"
;
import
{
CheckCircleIcon
,
ChevronRightIcon
,
ChevronLeftIcon
,
Code2Icon
,
LinkIcon
,
ListTodoIcon
,
Bookmark
Icon
}
from
"lucide-react"
;
import
{
observer
}
from
"mobx-react-lite"
;
import
{
useState
}
from
"react"
;
import
DatePicker
from
"react-datepicker"
;
...
...
@@ -107,7 +107,7 @@ const StatisticsView = observer(() => {
onClick=
{
()
=>
memoFilterStore
.
addFilter
({
factor
:
"pinned"
,
value
:
""
})
}
>
<
div
className=
"w-auto flex justify-start items-center mr-1"
>
<
Pin
Icon
className=
"w-4 h-auto mr-1"
/>
<
Bookmark
Icon
className=
"w-4 h-auto mr-1"
/>
<
span
className=
"block text-sm"
>
Pinned
</
span
>
</
div
>
<
span
className=
"text-sm truncate"
>
{
userStore
.
state
.
currentUserStats
.
pinnedMemos
.
length
}
</
span
>
...
...
web/src/pages/Home.tsx
View file @
34ab8834
...
...
@@ -59,6 +59,7 @@ const Home = observer(() => {
?
dayjs
(
a
.
displayTime
).
unix
()
-
dayjs
(
b
.
displayTime
).
unix
()
:
dayjs
(
b
.
displayTime
).
unix
()
-
dayjs
(
a
.
displayTime
).
unix
(),
)
.
sort
((
a
,
b
)
=>
Number
(
b
.
pinned
)
-
Number
(
a
.
pinned
))
}
owner=
{
user
.
name
}
direction=
{
viewStore
.
state
.
orderByTimeAsc
?
Direction
.
ASC
:
Direction
.
DESC
}
...
...
web/src/pages/UserProfile.tsx
View file @
34ab8834
...
...
@@ -110,6 +110,7 @@ const UserProfile = observer(() => {
?
dayjs
(
a
.
displayTime
).
unix
()
-
dayjs
(
b
.
displayTime
).
unix
()
:
dayjs
(
b
.
displayTime
).
unix
()
-
dayjs
(
a
.
displayTime
).
unix
(),
)
.
sort
((
a
,
b
)
=>
Number
(
b
.
pinned
)
-
Number
(
a
.
pinned
))
}
owner=
{
user
.
name
}
direction=
{
viewStore
.
state
.
orderByTimeAsc
?
Direction
.
ASC
:
Direction
.
DESC
}
...
...
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