aboutsummaryrefslogtreecommitdiff
path: root/src/guff.cr
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-05-24 18:49:22 -0400
committerPaul Duncan <pabs@pablotron.org>2016-05-24 18:49:22 -0400
commit83242fd94df0280e7793caef912d7a12b240fcec (patch)
treec410165daecaa9cf7bd8a7e68030ce5b53aded4f /src/guff.cr
parenta81c0884503bc2d16c6ba49774702b394e8fc265 (diff)
downloadguff-83242fd94df0280e7793caef912d7a12b240fcec.tar.bz2
guff-83242fd94df0280e7793caef912d7a12b240fcec.zip
add user.get_users
Diffstat (limited to 'src/guff.cr')
-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