mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
adding optional filter for account listing
This commit is contained in:
parent
889e6b4cc7
commit
8340290fab
@ -8,11 +8,21 @@ import (
|
|||||||
//GetAccountListing retrieves profile list of publicly accessible accounts
|
//GetAccountListing retrieves profile list of publicly accessible accounts
|
||||||
func GetAccountListing(w http.ResponseWriter, r *http.Request) {
|
func GetAccountListing(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
filter := r.FormValue("filter")
|
||||||
var accounts []store.Account
|
var accounts []store.Account
|
||||||
if err := store.DB.Preload("AccountDetail").Where("searchable = ? AND disabled = ?", true, false).Find(&accounts).Error; err != nil {
|
if filter == "" {
|
||||||
ErrResponse(w, http.StatusInternalServerError, err)
|
if err := store.DB.Order("id desc").Limit(16).Preload("AccountDetail").Where("searchable = ? AND disabled = ?", true, false).Find(&accounts).Error; err != nil {
|
||||||
return
|
ErrResponse(w, http.StatusInternalServerError, err)
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
username := "%" + filter + "%"
|
||||||
|
PrintMsg(username);
|
||||||
|
if err := store.DB.Order("id desc").Limit(16).Preload("AccountDetail").Where("username LIKE ? AND searchable = ? AND disabled = ?", username, true, false).Find(&accounts).Error; err != nil {
|
||||||
|
ErrResponse(w, http.StatusInternalServerError, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
profiles := []CardProfile{}
|
profiles := []CardProfile{}
|
||||||
for _, account := range accounts {
|
for _, account := range accounts {
|
||||||
|
Loading…
Reference in New Issue
Block a user