Class: UiChanged::ScreenshotsController
- Inherits:
-
ScreenshotsControllerBase
- Object
- ActionController::Base
- ApplicationController
- ScreenshotsControllerBase
- UiChanged::ScreenshotsController
- Defined in:
- app/controllers/ui_changed/screenshots_controller.rb
Instance Method Summary collapse
-
#cancel ⇒ Object
POST /screenshots/ignored.
-
#compares ⇒ Object
GET /screenshots/compares.
-
#controls ⇒ Object
GET /screenshots/controls.
-
#crawl_status ⇒ Object
GET /screenshots/crawl_status.json.
-
#destroy ⇒ Object
DELETE /screenshots/destroy.
-
#destroy_all_compares ⇒ Object
DELETE /screenshots/destroy_all_compares.
-
#destroy_all_controls ⇒ Object
DELETE /screenshots/destroy_all_controls.
-
#destroy_all_tests ⇒ Object
DELETE /screenshots/destroy_all_tests.
-
#diff ⇒ Object
GET /screenshots/diff.
-
#diffs ⇒ Object
GET /screenshots/diffs.
-
#index ⇒ Object
GET /screenshots.
-
#remove_all_diffs_and_tests ⇒ Object
remove all diffs & tests DELETE /screenshots/remove_all_diffs_and_tests.
-
#remove_diff_and_test ⇒ Object
DELETE /screenshots/remove_diff_and_test.
-
#set_all_tests_as_control ⇒ Object
set tests as controls and DELETE controls and DELETE diffs POST /screenshots/set_all_tests_as_control.
-
#set_test_as_control ⇒ Object
POST /screenshots/set_test_as_control.
-
#start_all ⇒ Object
POST /screenshots/start_all.
-
#start_compare ⇒ Object
POST /screenshots/start_compare.
-
#start_control ⇒ Object
POST /screenshots/start_control.
-
#start_control_compare ⇒ Object
POST /screenshots/start_control_compare.
-
#start_control_test ⇒ Object
POST /screenshots/start_control_test.
-
#start_test ⇒ Object
POST /screenshots/start_test.
-
#start_test_compare ⇒ Object
POST /screenshots/start_test_compare.
-
#tests ⇒ Object
GET /screenshots/tests.
Methods inherited from ScreenshotsControllerBase
Instance Method Details
#cancel ⇒ Object
POST /screenshots/ignored
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 55 def cancel # there has got to be a sexy ruby way of doing this crawl_statuses.each do |job| next unless is_job_running(job.status) job_id = job.uuid puts 'cancelling job_id: ' + job_id.to_s Resque::Plugins::Status::Hash.kill(job_id) end # and for good measure `redis-cli FLUSHALL` head :ok end |
#compares ⇒ Object
GET /screenshots/compares
85 86 87 88 89 90 91 92 93 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 85 def compares params[:sort] ||= "ui_changed_screenshots.url asc" @screenshots = UiChanged::Screenshot.search(params[:search]).not_in_ignored.where(:is_compare => true) .paginate(:page => params[:page], :per_page => params[:per_page], :order => params[:sort]) @type = "Compare" render "ui_changed/screenshots/screenshots" end |
#controls ⇒ Object
GET /screenshots/controls
96 97 98 99 100 101 102 103 104 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 96 def controls params[:sort] ||= "ui_changed_screenshots.url asc" @screenshots = UiChanged::Screenshot.search(params[:search]).not_in_ignored.where(:is_control => true) .paginate(:page => params[:page], :per_page => params[:per_page], :order => params[:sort]) @type = "Control" render "ui_changed/screenshots/screenshots" end |
#crawl_status ⇒ Object
GET /screenshots/crawl_status.json
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 14 def crawl_status first_status = crawl_statuses.first screenshots = [] if first_status screenshots = UiChanged::Screenshot.where("created_at > ?", first_status.time).order("id desc").limit(50).reverse end job = job_running if job != nil job_running_status = job.status if job.name && job.name.include?("Control") job_running_type = "control" elsif job.name &&job.name.include?("Test") job_running_type = "test" elsif job.name job_running_type = "compare" end end diff_count = UiChanged::Screenshot.not_in_ignored.where(:diff_found => true).count control_count = UiChanged::Screenshot.not_in_ignored.where(:is_control => true).count test_count = UiChanged::Screenshot.not_in_ignored.where(:is_test => true).count compare_count = UiChanged::Screenshot.not_in_ignored.where(:is_compare => true).count render :json => [{ :screenshots => screenshots, :counts => { :diff => diff_count, :control => control_count, :test => test_count, :compare => compare_count, }, :worker => { :running_status => job_running_status, :running_type => job_running_type, :first_status => first_status ? first_status.status : "" } }] end |
#destroy ⇒ Object
DELETE /screenshots/destroy
125 126 127 128 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 125 def destroy UiChanged::Screenshot.destroy_entries_and_images(params[:id].split(",")) head :ok end |
#destroy_all_compares ⇒ Object
DELETE /screenshots/destroy_all_compares
143 144 145 146 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 143 def destroy_all_compares UiChanged::Screenshot.delete_all_compares head :ok end |
#destroy_all_controls ⇒ Object
DELETE /screenshots/destroy_all_controls
131 132 133 134 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 131 def destroy_all_controls UiChanged::Screenshot.delete_all_controls head :ok end |
#destroy_all_tests ⇒ Object
DELETE /screenshots/destroy_all_tests
137 138 139 140 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 137 def destroy_all_tests UiChanged::Screenshot.delete_all_tests head :ok end |
#diff ⇒ Object
GET /screenshots/diff
118 119 120 121 122 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 118 def diff @diff = UiChanged::Screenshot.find(params[:diff_id]) @control = UiChanged::Screenshot.find(@diff.control_id) @test = UiChanged::Screenshot.find(@diff.test_id) end |
#diffs ⇒ Object
GET /screenshots/diffs
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 71 def diffs params[:sort] ||= "image_file_size desc" @diffs = UiChanged::Screenshot.search(params[:search]).not_in_ignored.where(:diff_found => true).paginate(:page => params[:page], :per_page => params[:per_page], :order => params[:sort]) @all_screenshots = [] @diffs.each do |diff| control = UiChanged::Screenshot.find(diff.control_id) test = UiChanged::Screenshot.find(diff.test_id) @all_screenshots << UiChanged::AllScreenshot.new(control, test, diff) end end |
#index ⇒ Object
GET /screenshots
9 10 11 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 9 def index @crawl_working = is_any_job_running_or_queued ? "true" : "false" end |
#remove_all_diffs_and_tests ⇒ Object
remove all diffs & tests DELETE /screenshots/remove_all_diffs_and_tests
150 151 152 153 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 150 def remove_all_diffs_and_tests UiChanged::Screenshot.remove_all_diffs_and_tests head :ok end |
#remove_diff_and_test ⇒ Object
DELETE /screenshots/remove_diff_and_test
156 157 158 159 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 156 def remove_diff_and_test UiChanged::Screenshot.remove_diffs_and_tests(params[:id].split(",")) head :ok end |
#set_all_tests_as_control ⇒ Object
set tests as controls and DELETE controls and DELETE diffs POST /screenshots/set_all_tests_as_control
163 164 165 166 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 163 def set_all_tests_as_control UiChanged::Screenshot.set_all_tests_as_controls head :ok end |
#set_test_as_control ⇒ Object
POST /screenshots/set_test_as_control
169 170 171 172 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 169 def set_test_as_control UiChanged::Screenshot.set_tests_as_controls(params[:id].split(",")) head :ok end |
#start_all ⇒ Object
POST /screenshots/start_all
177 178 179 180 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 177 def start_all UiChanged::Screenshot.async_crawl_and_compare head :ok end |
#start_compare ⇒ Object
POST /screenshots/start_compare
213 214 215 216 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 213 def start_compare UiChanged::Screenshot.start_async_compare head :ok end |
#start_control ⇒ Object
POST /screenshots/start_control
183 184 185 186 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 183 def start_control UiChanged::Screenshot.start_async_crawl_for_control head :ok end |
#start_control_compare ⇒ Object
POST /screenshots/start_control_compare
201 202 203 204 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 201 def start_control_compare UiChanged::Screenshot.start_async_crawl_for_control_and_compare head :ok end |
#start_control_test ⇒ Object
POST /screenshots/start_control_test
195 196 197 198 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 195 def start_control_test UiChanged::Screenshot.start_async_crawl_for_control_and_test head :ok end |
#start_test ⇒ Object
POST /screenshots/start_test
189 190 191 192 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 189 def start_test UiChanged::Screenshot.start_async_crawl_for_test head :ok end |
#start_test_compare ⇒ Object
POST /screenshots/start_test_compare
207 208 209 210 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 207 def start_test_compare UiChanged::Screenshot.start_async_crawl_for_test_and_compare head :ok end |
#tests ⇒ Object
GET /screenshots/tests
107 108 109 110 111 112 113 114 115 |
# File 'app/controllers/ui_changed/screenshots_controller.rb', line 107 def tests params[:sort] ||= "ui_changed_screenshots.url asc" @screenshots = UiChanged::Screenshot.search(params[:search]).not_in_ignored.where(:is_test => true) .paginate(:page => params[:page], :per_page => params[:per_page], :order => params[:sort]) @type = "Test" render "ui_changed/screenshots/screenshots" end |