Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkeller34 committed Oct 24, 2016
1 parent d13eaca commit 158fc00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/ICDataServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ function handle(jr::UpdateJobRequest)
ZMQ.send(jobsock, ZMQ.Message(io))
end

function handle(r::ListUsersRequest)
io = IOBuffer()
serialize(io, Array{String}(listusers(dsn)[:username]))
ZMQ.send(jobsock, ZMQ.Message(io))
end

function listtables(dsn)
ODBC.query(dsn,
"""
Expand Down
10 changes: 8 additions & 2 deletions src/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ function userstable(dsn, path; filename="")
);
""")

# add "default" user in case it is absent from the config file.
ODBC.execute!(dsn, """
INSERT INTO users (username, first, last) VALUES ('default', 'No', 'Name')
ON CONFLICT (username) DO NOTHING;
""")

ipath = joinpath(path, filename)
if isfile(ipath)
for d in JSON.parsefile(ipath)["users"]
Expand All @@ -126,7 +132,7 @@ function userstable(dsn, path; filename="")
pstr = reduce((a,b)->a*","*b, "$ki = '$(d[ki])'" for ki in k)
query = """
INSERT INTO users ($kstr) VALUES ($vstr) ON CONFLICT (username)
DO UPDATE SET $pstr
DO UPDATE SET $pstr ;
"""
ODBC.execute!(dsn, query)
end
Expand All @@ -152,7 +158,7 @@ function servertable(dsn, path; filename="")
pstr = reduce((a,b)->a*","*b, "$ki = '$(d[ki])'" for ki in k)
query = """
INSERT INTO servers ($kstr) VALUES ($vstr) ON CONFLICT (alias)
DO UPDATE SET $pstr
DO UPDATE SET $pstr ;
"""
ODBC.execute!(dsn, query)
end
Expand Down

0 comments on commit 158fc00

Please sign in to comment.