Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -79,11 +79,11 @@ func ListActivityLogs(
|
||||
q.Page = 1
|
||||
}
|
||||
// limit <=0 → unlimited
|
||||
if q.Limit < 0 {
|
||||
q.Limit = 50
|
||||
if q.Limit <= 0 {
|
||||
q.Limit = 1000
|
||||
}
|
||||
if q.Limit > 200 {
|
||||
q.Limit = 200
|
||||
if q.Limit > 1000 {
|
||||
q.Limit = 1000
|
||||
}
|
||||
|
||||
offset := 0
|
||||
@@ -200,17 +200,13 @@ LEFT JOIN dfrole r ON r.id = ru.dfrole_id
|
||||
%s
|
||||
ORDER BY l.created_at DESC
|
||||
`, whereSQL)
|
||||
// LIMIT sadece istenirse
|
||||
if q.Limit > 0 {
|
||||
listSQL += fmt.Sprintf(
|
||||
" LIMIT $%d OFFSET $%d",
|
||||
len(listArgs)+1,
|
||||
len(listArgs)+2,
|
||||
)
|
||||
|
||||
listSQL += fmt.Sprintf(
|
||||
" LIMIT $%d OFFSET $%d",
|
||||
len(listArgs)+1,
|
||||
len(listArgs)+2,
|
||||
)
|
||||
|
||||
listArgs = append(listArgs, q.Limit, offset)
|
||||
}
|
||||
listArgs = append(listArgs, q.Limit, offset)
|
||||
|
||||
rows, err := db.QueryContext(ctx, listSQL, listArgs...)
|
||||
if err != nil {
|
||||
|
||||
@@ -36,13 +36,11 @@ func AdminActivityLogsHandler(pgDB *sql.DB) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
q.Limit = 1000
|
||||
if v := r.URL.Query().Get("limit"); v != "" {
|
||||
if i, err := strconv.Atoi(v); err == nil {
|
||||
if i, err := strconv.Atoi(v); err == nil && i > 0 {
|
||||
q.Limit = i
|
||||
}
|
||||
} else {
|
||||
// limit yoksa unlimited
|
||||
q.Limit = 0
|
||||
}
|
||||
|
||||
// filters
|
||||
|
||||
Reference in New Issue
Block a user