Skip to content

Commit 54a48b5

Browse files
committed
chore: remove random field
1 parent 2a8c4cb commit 54a48b5

File tree

8 files changed

+0
-31
lines changed

8 files changed

+0
-31
lines changed

store/db/mysql/memo.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
145145
orders = append(orders, "`created_ts` "+order)
146146
}
147147
orders = append(orders, "`id` "+order)
148-
if find.Random {
149-
orders = append(orders, "RAND()")
150-
}
151-
152148
fields := []string{
153149
"`memo`.`id` AS `id`",
154150
"`memo`.`uid` AS `uid`",

store/db/mysql/user.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package mysql
33
import (
44
"context"
55
"fmt"
6-
"slices"
76
"strings"
87

98
"github.com/pkg/errors"
@@ -99,10 +98,6 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
9998
}
10099

101100
orderBy := []string{"`created_ts` DESC", "`row_status` DESC"}
102-
if find.Random {
103-
orderBy = slices.Concat([]string{"RAND()"}, orderBy)
104-
}
105-
106101
query := "SELECT `id`, `username`, `role`, `email`, `nickname`, `password_hash`, `avatar_url`, `description`, UNIX_TIMESTAMP(`created_ts`), UNIX_TIMESTAMP(`updated_ts`), `row_status` FROM `user` WHERE " + strings.Join(where, " AND ") + " ORDER BY " + strings.Join(orderBy, ", ")
107102
if v := find.Limit; v != nil {
108103
query += fmt.Sprintf(" LIMIT %d", *v)

store/db/postgres/memo.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
137137
orders = append(orders, "created_ts "+order)
138138
}
139139
orders = append(orders, "id "+order)
140-
if find.Random {
141-
orders = append(orders, "RAND()")
142-
}
143-
144140
fields := []string{
145141
`memo.id AS id`,
146142
`memo.uid AS uid`,

store/db/postgres/user.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package postgres
33
import (
44
"context"
55
"fmt"
6-
"slices"
76
"strings"
87

98
"github.com/usememos/memos/store"
@@ -101,10 +100,6 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
101100
}
102101

103102
orderBy := []string{"created_ts DESC", "row_status DESC"}
104-
if find.Random {
105-
orderBy = slices.Concat([]string{"RANDOM()"}, orderBy)
106-
}
107-
108103
query := `
109104
SELECT
110105
id,

store/db/sqlite/memo.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
137137
orderBy = append(orderBy, "`created_ts` "+order)
138138
}
139139
orderBy = append(orderBy, "`id` "+order)
140-
if find.Random {
141-
orderBy = []string{"RANDOM()"}
142-
}
143-
144140
fields := []string{
145141
"`memo`.`id` AS `id`",
146142
"`memo`.`uid` AS `uid`",

store/db/sqlite/user.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package sqlite
33
import (
44
"context"
55
"fmt"
6-
"slices"
76
"strings"
87

98
"github.com/usememos/memos/store"
@@ -102,10 +101,6 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
102101
}
103102

104103
orderBy := []string{"created_ts DESC", "row_status DESC"}
105-
if find.Random {
106-
orderBy = slices.Concat([]string{"RANDOM()"}, orderBy)
107-
}
108-
109104
query := `
110105
SELECT
111106
id,

store/memo.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ type FindMemo struct {
7373
PayloadFind *FindMemoPayload
7474
ExcludeContent bool
7575
ExcludeComments bool
76-
Random bool
7776
Filter *string
7877

7978
// Pagination

store/user.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ type FindUser struct {
8383
Email *string
8484
Nickname *string
8585

86-
// Random and limit are used in list users.
87-
// Whether to return random users.
88-
Random bool
8986
// The maximum number of users to return.
9087
Limit *int
9188
}

0 commit comments

Comments
 (0)