From f067e68d3d1d601b559e9f1c311b34da03a9acdb Mon Sep 17 00:00:00 2001 From: Andrey Ivanov Date: Mon, 11 Jan 2021 09:59:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A7=D1=83=D1=82=D1=8C=20=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/handlers/handlers.go | 21 ++++++++++++++++++++- templates/list.tmpl | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 1a85643..619b509 100755 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -93,7 +93,26 @@ func GetUserList(app application.App, user auth.User, r render.Render) { var users []auth.UserModel var tmp auth.UserModel var tmpTime string - var results, err = app.DB.Query(`SELECT id, name, surname, birthdate, gender, city FROM users`) + query := fmt.Sprintf(`SELECT + users.id as id, + users.name as name, + users.surname as surname, + users.birthdate as birthdate, + users.gender as gender, + users.city as city + FROM + users + WHERE + NOT users.id=%d + AND users.id NOT IN ( + SELECT + relations.friendId + FROM + relations + WHERE + relations.userId=%d)`, int(user.(*auth.UserModel).Id), int(user.(*auth.UserModel).Id)) + + var results, err = app.DB.Query(query) if err != nil || results == nil { err500("can't get user list from DB: ", err, r) } diff --git a/templates/list.tmpl b/templates/list.tmpl index f879c12..7f53aec 100644 --- a/templates/list.tmpl +++ b/templates/list.tmpl @@ -18,7 +18,7 @@ -

List of all users

+

List of all unrelated users