mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: remove random field
This commit is contained in:
@@ -145,10 +145,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
||||
orders = append(orders, "`created_ts` "+order)
|
||||
}
|
||||
orders = append(orders, "`id` "+order)
|
||||
if find.Random {
|
||||
orders = append(orders, "RAND()")
|
||||
}
|
||||
|
||||
fields := []string{
|
||||
"`memo`.`id` AS `id`",
|
||||
"`memo`.`uid` AS `uid`",
|
||||
|
@@ -3,7 +3,6 @@ package mysql
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -99,10 +98,6 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
|
||||
}
|
||||
|
||||
orderBy := []string{"`created_ts` DESC", "`row_status` DESC"}
|
||||
if find.Random {
|
||||
orderBy = slices.Concat([]string{"RAND()"}, orderBy)
|
||||
}
|
||||
|
||||
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, ", ")
|
||||
if v := find.Limit; v != nil {
|
||||
query += fmt.Sprintf(" LIMIT %d", *v)
|
||||
|
@@ -137,10 +137,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
||||
orders = append(orders, "created_ts "+order)
|
||||
}
|
||||
orders = append(orders, "id "+order)
|
||||
if find.Random {
|
||||
orders = append(orders, "RAND()")
|
||||
}
|
||||
|
||||
fields := []string{
|
||||
`memo.id AS id`,
|
||||
`memo.uid AS uid`,
|
||||
|
@@ -3,7 +3,6 @@ package postgres
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/usememos/memos/store"
|
||||
@@ -101,10 +100,6 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
|
||||
}
|
||||
|
||||
orderBy := []string{"created_ts DESC", "row_status DESC"}
|
||||
if find.Random {
|
||||
orderBy = slices.Concat([]string{"RANDOM()"}, orderBy)
|
||||
}
|
||||
|
||||
query := `
|
||||
SELECT
|
||||
id,
|
||||
|
@@ -137,10 +137,6 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo
|
||||
orderBy = append(orderBy, "`created_ts` "+order)
|
||||
}
|
||||
orderBy = append(orderBy, "`id` "+order)
|
||||
if find.Random {
|
||||
orderBy = []string{"RANDOM()"}
|
||||
}
|
||||
|
||||
fields := []string{
|
||||
"`memo`.`id` AS `id`",
|
||||
"`memo`.`uid` AS `uid`",
|
||||
|
@@ -3,7 +3,6 @@ package sqlite
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/usememos/memos/store"
|
||||
@@ -102,10 +101,6 @@ func (d *DB) ListUsers(ctx context.Context, find *store.FindUser) ([]*store.User
|
||||
}
|
||||
|
||||
orderBy := []string{"created_ts DESC", "row_status DESC"}
|
||||
if find.Random {
|
||||
orderBy = slices.Concat([]string{"RANDOM()"}, orderBy)
|
||||
}
|
||||
|
||||
query := `
|
||||
SELECT
|
||||
id,
|
||||
|
@@ -73,7 +73,6 @@ type FindMemo struct {
|
||||
PayloadFind *FindMemoPayload
|
||||
ExcludeContent bool
|
||||
ExcludeComments bool
|
||||
Random bool
|
||||
Filter *string
|
||||
|
||||
// Pagination
|
||||
|
@@ -83,9 +83,6 @@ type FindUser struct {
|
||||
Email *string
|
||||
Nickname *string
|
||||
|
||||
// Random and limit are used in list users.
|
||||
// Whether to return random users.
|
||||
Random bool
|
||||
// The maximum number of users to return.
|
||||
Limit *int
|
||||
}
|
||||
|
Reference in New Issue
Block a user