aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/guff.cr33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/guff.cr b/src/guff.cr
index 1caad59..b5ea71a 100644
--- a/src/guff.cr
+++ b/src/guff.cr
@@ -875,7 +875,7 @@ module Guff
sql = [] of String
args = [site_id.to_s]
- STDERR.puts "DEBUG: site_id = #{site_id}, year = #{year}, month = #{month}, day = #{day}, slug = \"#{slug}\""
+ # STDERR.puts "DEBUG: site_id = #{site_id}, year = #{year}, month = #{month}, day = #{day}, slug = \"#{slug}\""
if year
# add year filter
@@ -901,7 +901,7 @@ module Guff
args << slug
end
- STDERR.puts "DEBUG: args = #{args.to_json}"
+ # STDERR.puts "DEBUG: args = #{args.to_json}"
# exec query, build result
r = [] of Int64
@@ -1006,6 +1006,20 @@ module Guff
SET %s
WHERE user_id = ?
",
+
+ get_users: "
+ SELECT a.user_id,
+ a.name,
+ a.email,
+ a.is_active,
+ b.role
+
+ FROM users a
+ JOIN roles b
+ ON (b.role_id = a.role_id)
+
+ ORDER BY LOWER(a.email)
+ ",
}
def login(
@@ -1094,7 +1108,17 @@ module Guff
end
def get_users
- # TODO
+ rows = [] of Hash(String, String)
+
+ @context.dbs.ro.all(SQL[:get_users]) do |row|
+ # append row to result
+ rows << row.reduce({} of String => String) do |r, k, v|
+ r[k] = v.to_s
+ r
+ end
+ end
+
+ rows
end
end
@@ -1590,8 +1614,7 @@ module Guff
end
def do_user_get_users(params : HTTP::Params)
- # @context.models.user.get_users
- nil
+ @context.models.user.get_users
end
end
end