From 88e864d94c6764f9f651e927b20a497b5670e2bf Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 15 Oct 2010 09:34:45 +0200 Subject: fixed client:getVotes --- server/cldb.erl | 10 +++++++++- server/client.erl | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'server') 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 -- cgit v1.2.3