Permalink
Browse files

Add dups page

  • Loading branch information...
1 parent 6dc7d12 commit 516013d1f4a33c86a57486bcec5502ec38f4f6fb @rantav committed Apr 23, 2012
Showing with 34 additions and 0 deletions.
  1. +18 −0 app/controllers/dups_controller.rb
  2. +14 −0 app/views/dups/index.html.haml
  3. +2 −0 config/routes.rb
@@ -0,0 +1,18 @@
+class DupsController < ApplicationController
+
+ layout "wide"
+
+ # GET /dups
+ # GET /dups.json
+ def index
+ all = {}
+ PhysicalHost.all.each {|h| all[h.name] ? all[h.name]<<h.id.to_s : all[h.name] = [h.id.to_s]}
+
+ @dups = all.reject {|k,v| v.length < 2}
+ @dups = @dups.map {|k,v| {:name => k, :links => v.map {|i| '/physical_hosts/' + i}}}
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @dups }
+ end
+ end
+end
@@ -0,0 +1,14 @@
+%h1 Listing duplicates
+
+%table
+ %tr
+ %th Host
+ %th Duplicates
+
+ - @dups.each do |dup|
+ %tr
+ %td= dup[:name]
+ %td
+ - dup[:links].each do |link|
+ = link_to link, link
+
View
@@ -1,9 +1,11 @@
Onering::Application.routes.draw do
+
root :to => 'high_voltage/pages#show', :id => 'home'
match 'search' => 'physical_hosts#search'
+ resources :dups, :only => :index
resources :physical_racks
resources :datacenters
resources :physical_hosts do

0 comments on commit 516013d

Please sign in to comment.