Skip to content

Commit

Permalink
simplified mux lookup, added last change date per package in host view
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadlevy committed May 23, 2010
1 parent 7be5530 commit a4631c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/controllers/hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def index

def show
@host = Host.find(params[:id])
@search = Package.search params[:search]
@packages = @search.paginate(:conditions => {:muxes => {:host_id => @host}}, :joins => :muxes, :page => params[:page], :order => :name).uniq
@search = Mux.search params[:search]
@muxes = @search.paginate(:conditions => {:host_id => @host}, :joins => [:package, :version, :arch], :page => params[:page])
end

def new
Expand Down
8 changes: 0 additions & 8 deletions app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,4 @@ def to_s
name
end

def package_details pkg
a = []
Mux.all(:conditions => {:host_id => self, :package_id => pkg}, :include => [:version, :arch]).each do |m|
a << "#{m.version}(#{m.arch})"
end
return a
end

end
3 changes: 2 additions & 1 deletion app/views/common/_search.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<span class=pagination>
<% value ||= "name_like" -%>
<% form_for @search do |f|-%>
<%= f.text_field :name_like, :size => 10 %>
<%= f.text_field value, :size => 10 %>
<%= f.submit "Search" %>
<% end %>
</span>
20 changes: 12 additions & 8 deletions app/views/hosts/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<% title "#{h @host.name} (#{@host.os})" %>
<%= render "common/search" %>
<%= render "common/search", :value => :package_name_like %>
<table>
<tr>
<th>Package</th>
<th>Version(arch)</th>
<th>Version</th>
<th>Arch</th>
<th>Last changed</th>
</tr>
<% for package in @packages -%>
<% for mux in @muxes -%>
<tr>
<td><%= link_to h(package), package_path(package) %></td>
<td> <%= h @host.package_details(package).to_sentence %></td>
<td><%= link_to h(mux.package), package_path(mux.package) %></td>
<td><%= h mux.version %></td>
<td><%= h mux.arch %></td>
<td><%= time_ago_in_words mux.updated_at %></td>
</tr>
<% end -%>
</table>
<%= page_entries_info @packages %>
<%= will_paginate @packages %>
<%= page_entries_info @muxes %>
<%= will_paginate @muxes %>

<p>
<%= link_to "View All", hosts_path %>
<span class="pagination">last updated at <%= @host.updated_at %></span>
<span class="pagination">last updated <%= time_ago_in_words @host.updated_at %> ago</span>
</p>

0 comments on commit a4631c4

Please sign in to comment.