Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: remove random field

johnnyjoy54a48b58d70e
diff --git a/store/db/mysql/memo.go b/store/db/mysql/memo.go
index 271fe0c9d..caca7554a 100644
--- a/store/db/mysql/memo.go
+++ b/store/db/mysql/memo.go
@@ -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`",
diff --git a/store/db/mysql/user.go b/store/db/mysql/user.go
index 1f9c4cf62..9bf2d9640 100644
--- a/store/db/mysql/user.go
+++ b/store/db/mysql/user.go
@@ -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)
diff --git a/store/db/postgres/memo.go b/store/db/postgres/memo.go
index 104c8a04c..4dbb399d9 100644
--- a/store/db/postgres/memo.go
+++ b/store/db/postgres/memo.go
@@ -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`,
diff --git a/store/db/postgres/user.go b/store/db/postgres/user.go
index 13e2890c7..2bdf6f16b 100644
--- a/store/db/postgres/user.go
+++ b/store/db/postgres/user.go
@@ -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,
diff --git a/store/db/sqlite/memo.go b/store/db/sqlite/memo.go
index a66d7c00c..a40a4890f 100644
--- a/store/db/sqlite/memo.go
+++ b/store/db/sqlite/memo.go
@@ -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`",
diff --git a/store/db/sqlite/user.go b/store/db/sqlite/user.go
index 7efb690e4..6c885fd7d 100644
--- a/store/db/sqlite/user.go
+++ b/store/db/sqlite/user.go
@@ -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,
diff --git a/store/memo.go b/store/memo.go
index 58172fa21..79ed72c8d 100644
--- a/store/memo.go
+++ b/store/memo.go
@@ -73,7 +73,6 @@ type FindMemo struct {
PayloadFind *FindMemoPayload
ExcludeContent bool
ExcludeComments bool
- Random bool
Filter *string
// Pagination
diff --git a/store/user.go b/store/user.go
index e61d876ee..8b5c0fd31 100644
--- a/store/user.go
+++ b/store/user.go
@@ -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
}