diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-10-15 09:34:45 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2010-10-15 09:34:45 +0200 |
commit | 88e864d94c6764f9f651e927b20a497b5670e2bf (patch) | |
tree | 4f37e6f3f3cec49d8e5dc714df906dd4829737ce | |
parent | 89accd8f916eea3dd9e3f873350a2b8ed0c51ec4 (diff) | |
download | erlang-88e864d94c6764f9f651e927b20a497b5670e2bf.tar.gz erlang-88e864d94c6764f9f651e927b20a497b5670e2bf.tar.xz erlang-88e864d94c6764f9f651e927b20a497b5670e2bf.zip |
fixed client:getVotes
-rw-r--r-- | server/cldb.erl | 10 | ||||
-rw-r--r-- | server/client.erl | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/server/cldb.erl b/server/cldb.erl index 28815a6..e6f414e 100644 --- a/server/cldb.erl +++ b/server/cldb.erl @@ -1,7 +1,7 @@ % The clientdatabase -module(cldb). --export([init/0, all/0, find/1, login/2, dec_vote/1, inc_vote/1, register/3, check_rights/1, update_votes/0, logout/1, set_client_pid/2]). +-export([init/0, all/0, find/1, login/2, dec_vote/1, inc_vote/1, register/3, check_rights/1, update_votes/0, logout/1, set_client_pid/2, get_votes/1]). -record(user, {name, passwd, votes, logged_in, pid, rights}). init() -> @@ -163,3 +163,11 @@ give_votes([User|Rest]) -> inc_vote(User#user.name), give_votes(Rest); give_votes([]) -> ok. + +get_votes(User) -> + case find(User) of + {atomic, [UserRow|_]} -> + {ok, UserRow#user.votes}; + _ -> + {error, user_not_found} + end. diff --git a/server/client.erl b/server/client.erl index 421280b..c5beda7 100644 --- a/server/client.erl +++ b/server/client.erl @@ -47,7 +47,7 @@ loop(Client, User) -> execute(Client, fun() -> media:all() end); get_votes -> - execute(Client, fun() -> media:getVotes(Client) end); + execute(Client, fun() -> cldb:get_votes(User) end); {vote, Artist, Title} -> %% only allow vote if user has vote to give away |