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
Gemfile.lock
| ... | ... | @@ -155,6 +155,7 @@ GEM |
| 155 | 155 | responders (0.6.4) |
| 156 | 156 | rest-client (1.6.7) |
| 157 | 157 | mime-types (>= 1.16) |
| 158 | + ri_cal (0.8.8) | |
| 158 | 159 | rspec (2.6.0) |
| 159 | 160 | rspec-core (~> 2.6.0) |
| 160 | 161 | rspec-expectations (~> 2.6.0) |
| ... | ... | @@ -230,6 +231,7 @@ DEPENDENCIES |
| 230 | 231 | oruen_redmine_client |
| 231 | 232 | pivotal-tracker |
| 232 | 233 | rails (= 3.0.10) |
| 234 | + ri_cal | |
| 233 | 235 | rspec (~> 2.6) |
| 234 | 236 | rspec-rails (~> 2.6) |
| 235 | 237 | ruby-debug | ... | ... |
app/controllers/deploys_controller.rb
| ... | ... | @@ -16,7 +16,9 @@ class DeploysController < ApplicationController |
| 16 | 16 | app = App.find(params[:app_id]) |
| 17 | 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 | 22 | end |
| 21 | 23 | |
| 22 | 24 | private | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -3,6 +3,21 @@ module ApplicationHelper |
| 3 | 3 | create_percentage_table_for(problem) {|notice| notice.message} |
| 4 | 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 | 21 | def user_agent_graph(problem) |
| 7 | 22 | create_percentage_table_for(problem) {|notice| pretty_user_agent(notice.user_agent)} |
| 8 | 23 | end | ... | ... |
| ... | ... | @@ -0,0 +1 @@ |
| 1 | += generate_ical(@app.deploys.order_by(:created_at.asc)) | ... | ... |