Commit 747ca77edc5fc5afc6cde31ba39b93432b7f6df3
1 parent
3851c29b
Exists in
master
and in
1 other branch
Subscribe to application deployments in iCal.
Use
http://example.com/apps/<app_id>/deploys.ics?auth_token=xyz
to subscribe to deployments timings of an application in iCal.
Showing
5 changed files
with
23 additions
and
1 deletions
Show diff stats
Gemfile
| @@ -23,6 +23,8 @@ platform :ruby do | @@ -23,6 +23,8 @@ platform :ruby do | ||
| 23 | gem 'bson_ext', '~> 1.4.0' | 23 | gem 'bson_ext', '~> 1.4.0' |
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | +gem 'ri_cal' | ||
| 27 | + | ||
| 26 | group :development, :test do | 28 | group :development, :test do |
| 27 | gem 'rspec-rails', '~> 2.6' | 29 | gem 'rspec-rails', '~> 2.6' |
| 28 | gem 'webmock', :require => false | 30 | gem 'webmock', :require => false |
Gemfile.lock
| @@ -155,6 +155,7 @@ GEM | @@ -155,6 +155,7 @@ GEM | ||
| 155 | responders (0.6.4) | 155 | responders (0.6.4) |
| 156 | rest-client (1.6.7) | 156 | rest-client (1.6.7) |
| 157 | mime-types (>= 1.16) | 157 | mime-types (>= 1.16) |
| 158 | + ri_cal (0.8.8) | ||
| 158 | rspec (2.6.0) | 159 | rspec (2.6.0) |
| 159 | rspec-core (~> 2.6.0) | 160 | rspec-core (~> 2.6.0) |
| 160 | rspec-expectations (~> 2.6.0) | 161 | rspec-expectations (~> 2.6.0) |
| @@ -230,6 +231,7 @@ DEPENDENCIES | @@ -230,6 +231,7 @@ DEPENDENCIES | ||
| 230 | oruen_redmine_client | 231 | oruen_redmine_client |
| 231 | pivotal-tracker | 232 | pivotal-tracker |
| 232 | rails (= 3.0.10) | 233 | rails (= 3.0.10) |
| 234 | + ri_cal | ||
| 233 | rspec (~> 2.6) | 235 | rspec (~> 2.6) |
| 234 | rspec-rails (~> 2.6) | 236 | rspec-rails (~> 2.6) |
| 235 | ruby-debug | 237 | ruby-debug |
app/controllers/deploys_controller.rb
| @@ -16,7 +16,9 @@ class DeploysController < ApplicationController | @@ -16,7 +16,9 @@ class DeploysController < ApplicationController | ||
| 16 | app = App.find(params[:app_id]) | 16 | app = App.find(params[:app_id]) |
| 17 | raise Mongoid::Errors::DocumentNotFound.new(App, app.id) unless current_user.admin? || current_user.watching?(app) | 17 | raise Mongoid::Errors::DocumentNotFound.new(App, app.id) unless current_user.admin? || current_user.watching?(app) |
| 18 | 18 | ||
| 19 | - @deploys = app.deploys.order_by(:created_at.desc).paginate(:page => params[:page], :per_page => 10) | 19 | + @deploys = app.deploys.order_by(:created_at.desc). |
| 20 | + paginate(:page => params[:page], :per_page => 10) | ||
| 21 | + @app = app | ||
| 20 | end | 22 | end |
| 21 | 23 | ||
| 22 | private | 24 | private |
app/helpers/application_helper.rb
| @@ -3,6 +3,21 @@ module ApplicationHelper | @@ -3,6 +3,21 @@ module ApplicationHelper | ||
| 3 | create_percentage_table_for(problem) {|notice| notice.message} | 3 | create_percentage_table_for(problem) {|notice| notice.message} |
| 4 | end | 4 | end |
| 5 | 5 | ||
| 6 | + def generate_ical(deploys) | ||
| 7 | + RiCal.Calendar do |cal| | ||
| 8 | + deploys.each_with_index do |deploy,idx| | ||
| 9 | + cal.event do |event| | ||
| 10 | + event.summary = "#{idx+1} #{deploy.repository}" | ||
| 11 | + event.description = deploy.revision | ||
| 12 | + event.dtstart = deploy.created_at | ||
| 13 | + event.dtend = deploy.created_at + 60.minutes | ||
| 14 | + event.location = deploy.environment | ||
| 15 | + event.organizer = deploy.username | ||
| 16 | + end | ||
| 17 | + end | ||
| 18 | + end.to_s | ||
| 19 | + end | ||
| 20 | + | ||
| 6 | def user_agent_graph(problem) | 21 | def user_agent_graph(problem) |
| 7 | create_percentage_table_for(problem) {|notice| pretty_user_agent(notice.user_agent)} | 22 | create_percentage_table_for(problem) {|notice| pretty_user_agent(notice.user_agent)} |
| 8 | end | 23 | end |
| @@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
| 1 | += generate_ical(@app.deploys.order_by(:created_at.asc)) |