Skip to content

Commit

Permalink
[api] improve the ruby dialect, refactored variable index, using each…
Browse files Browse the repository at this point in the history
…_with_index method
  • Loading branch information
vpereira authored and adrianschroeter committed Feb 4, 2015
1 parent e9e422c commit db69f34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/api/app/models/buildresult.rb
Expand Up @@ -5,24 +5,22 @@ class Buildresult < ActiveXML::Node
@@status_hash = nil

def self.avail_status_values
return Avail_status_values
Avail_status_values
end

def self.code2index(code)
unless @@status_hash
index = 0
@@status_hash = Hash.new
Avail_status_values.each do |s|
Avail_status_values.each_with_index do |s,index|
@@status_hash[s] = index
index += 1
end
end
raise ArgumentError, "code '#{code}' unknown #{@@status_hash.inspect}" unless @@status_hash[code]
return @@status_hash[code]
@@status_hash[code]
end

def self.index2code(index)
return Avail_status_values[index]
Avail_status_values[index]
end

end
2 changes: 1 addition & 1 deletion src/api/app/models/channel_binary.rb
Expand Up @@ -16,7 +16,7 @@ def self.find_by_project_and_package(project, package)
maintained_projects = Project.get_maintenance_project.expand_maintained_projects

# I am not able to construct this with rails in a valid way :/
return ChannelBinary.find_by_sql(['SELECT channel_binaries.* FROM channel_binaries LEFT JOIN channel_binary_lists ON channel_binary_lists.id = channel_binaries.channel_binary_list_id LEFT JOIN channels ON channel_binary_lists.channel_id = channels.id LEFT JOIN packages ON channels.package_id = packages.id WHERE (channel_binary_lists.project_id = ? and package = ? and packages.project_id IN (?))', project.id, package, maintained_projects])
ChannelBinary.find_by_sql(['SELECT channel_binaries.* FROM channel_binaries LEFT JOIN channel_binary_lists ON channel_binary_lists.id = channel_binaries.channel_binary_list_id LEFT JOIN channels ON channel_binary_lists.channel_id = channels.id LEFT JOIN packages ON channels.package_id = packages.id WHERE (channel_binary_lists.project_id = ? and package = ? and packages.project_id IN (?))', project.id, package, maintained_projects])
end

def create_channel_package_into(project)
Expand Down

0 comments on commit db69f34

Please sign in to comment.