From c6cd449132c45625d6453d1ffed08bc9142db8d3 Mon Sep 17 00:00:00 2001 From: John Dong Date: Wed, 15 Aug 2007 12:30:25 -0400 Subject: [PATCH] XMLRPC: Add translator from candidate ID to names --- app/apis/selectricity_api.rb | 1 + app/models/selectricity_service.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/apis/selectricity_api.rb b/app/apis/selectricity_api.rb index d478a5a..da2f6f7 100644 --- a/app/apis/selectricity_api.rb +++ b/app/apis/selectricity_api.rb @@ -15,6 +15,7 @@ class SelectricityAPI < ActionWebService::API::Base api_method :cast_quickvote, :expects => [:int, :int, [[:int]]], :returns => [:string] api_method :get_quickvote_results, :expects => [:string], :returns => [VoteResultStruct] api_method :get_quickvote_candidate_map, :expects => [:string], :returns => [CandidateMap] + api_method :quickvote_candidate_ids_to_names, :expects => [:string,[:int]], :returns => [[:string]] end diff --git a/app/models/selectricity_service.rb b/app/models/selectricity_service.rb index 75d2e3e..eb09d8d 100644 --- a/app/models/selectricity_service.rb +++ b/app/models/selectricity_service.rb @@ -5,6 +5,23 @@ class SelectricityService < ActionWebService::Base def cast_quickvote(election_id, vote_id, vote_list) #Obviously not implemented end + def quickvote_candidate_ids_to_names(shortname, id_list) + qv=QuickVote.ident_to_quickvote(shortname) + candidates={} + return [] unless qv + qv.results + qv.candidates.each {|c| candidates[c.id] = c} + results=[] + id_list.each { |id| + name=candidates[id] + if name + results << name + else + results << "" + end + } + results + end def get_quickvote_results(shortname) #TODO: Validate shortname qv=QuickVote.ident_to_quickvote(shortname) -- 2.30.2