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, "`created_ts` "+order)
|
||||||
}
|
}
|
||||||
orders = append(orders, "`id` "+order)
|
orders = append(orders, "`id` "+order)
|
||||||
if find.Random {
|
|
||||||
orders = append(orders, "RAND()")
|
|
||||||
}
|
|
||||||
|
|
||||||
fields := []string{
|
fields := []string{
|
||||||
"`memo`.`id` AS `id`",
|
"`memo`.`id` AS `id`",
|
||||||
"`memo`.`uid` AS `uid`",
|
"`memo`.`uid` AS `uid`",
|
||||||
|
@@ -3,7 +3,6 @@ package mysql
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"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"}
|
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, ", ")
|
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 {
|
if v := find.Limit; v != nil {
|
||||||
query += fmt.Sprintf(" LIMIT %d", *v)
|
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, "created_ts "+order)
|
||||||
}
|
}
|
||||||
orders = append(orders, "id "+order)
|
orders = append(orders, "id "+order)
|
||||||
if find.Random {
|
|
||||||
orders = append(orders, "RAND()")
|
|
||||||
}
|
|
||||||
|
|
||||||
fields := []string{
|
fields := []string{
|
||||||
`memo.id AS id`,
|
`memo.id AS id`,
|
||||||
`memo.uid AS uid`,
|
`memo.uid AS uid`,
|
||||||
|
@@ -3,7 +3,6 @@ package postgres
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/usememos/memos/store"
|
"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"}
|
orderBy := []string{"created_ts DESC", "row_status DESC"}
|
||||||
if find.Random {
|
|
||||||
orderBy = slices.Concat([]string{"RANDOM()"}, orderBy)
|
|
||||||
}
|
|
||||||
|
|
||||||
query := `
|
query := `
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
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, "`created_ts` "+order)
|
||||||
}
|
}
|
||||||
orderBy = append(orderBy, "`id` "+order)
|
orderBy = append(orderBy, "`id` "+order)
|
||||||
if find.Random {
|
|
||||||
orderBy = []string{"RANDOM()"}
|
|
||||||
}
|
|
||||||
|
|
||||||
fields := []string{
|
fields := []string{
|
||||||
"`memo`.`id` AS `id`",
|
"`memo`.`id` AS `id`",
|
||||||
"`memo`.`uid` AS `uid`",
|
"`memo`.`uid` AS `uid`",
|
||||||
|
@@ -3,7 +3,6 @@ package sqlite
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/usememos/memos/store"
|
"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"}
|
orderBy := []string{"created_ts DESC", "row_status DESC"}
|
||||||
if find.Random {
|
|
||||||
orderBy = slices.Concat([]string{"RANDOM()"}, orderBy)
|
|
||||||
}
|
|
||||||
|
|
||||||
query := `
|
query := `
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
|
@@ -73,7 +73,6 @@ type FindMemo struct {
|
|||||||
PayloadFind *FindMemoPayload
|
PayloadFind *FindMemoPayload
|
||||||
ExcludeContent bool
|
ExcludeContent bool
|
||||||
ExcludeComments bool
|
ExcludeComments bool
|
||||||
Random bool
|
|
||||||
Filter *string
|
Filter *string
|
||||||
|
|
||||||
// Pagination
|
// Pagination
|
||||||
|
@@ -83,9 +83,6 @@ type FindUser struct {
|
|||||||
Email *string
|
Email *string
|
||||||
Nickname *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.
|
// The maximum number of users to return.
|
||||||
Limit *int
|
Limit *int
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user