Commit ab4890bac17a239e0b4539ae3226c11997817b20
1 parent
5528df16
Exists in
master
and in
1 other branch
Added ics format for a problem, listing its linked notices in ics format.
Strictly this shouldn't be necessary however our use case is that we're monitoring a particular problem and what to know whether there is a pattern in when it's occurring. Hence iCal and ics format. On branch: master
Showing
3 changed files
with
19 additions
and
0 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -3,6 +3,22 @@ module ApplicationHelper | @@ -3,6 +3,22 @@ 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_problem_ical(notices) | ||
7 | + RiCal.Calendar do |cal| | ||
8 | + notices.each_with_index do |notice,idx| | ||
9 | + cal.event do |event| | ||
10 | + event.summary = "#{idx+1} #{notice.message.to_s}" | ||
11 | + event.description = notice.request['url'] | ||
12 | + event.dtstart = notice.created_at.utc | ||
13 | + event.dtend = notice.created_at.utc + 60.minutes | ||
14 | + event.organizer = notice.server_environment && notice.server_environment["hostname"] | ||
15 | + event.location = notice.server_environment && notice.server_environment["project-root"] | ||
16 | + event.url = app_err_url(:app_id => notice.problem.app.id, :id => notice.problem) | ||
17 | + end | ||
18 | + end | ||
19 | + end.to_s | ||
20 | + end | ||
21 | + | ||
6 | def generate_ical(deploys) | 22 | def generate_ical(deploys) |
7 | RiCal.Calendar { |cal| | 23 | RiCal.Calendar { |cal| |
8 | deploys.each_with_index do |deploy,idx| | 24 | deploys.each_with_index do |deploy,idx| |
app/views/errs/show.html.haml
@@ -11,6 +11,8 @@ | @@ -11,6 +11,8 @@ | ||
11 | %strong Last Notice: | 11 | %strong Last Notice: |
12 | = last_notice_at(@problem).to_s(:micro) | 12 | = last_notice_at(@problem).to_s(:micro) |
13 | - content_for :action_bar do | 13 | - content_for :action_bar do |
14 | + - if current_user.authentication_token | ||
15 | + %span= link_to 'iCal', app_err_path(:app_id => @app.id, :id => @problem.id, :format => "ics", :auth_token => current_user.authentication_token), :class => "calendar_link" | ||
14 | - if @problem.app.issue_tracker_configured? | 16 | - if @problem.app.issue_tracker_configured? |
15 | - if @problem.issue_link.blank? | 17 | - if @problem.issue_link.blank? |
16 | %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "#{@app.issue_tracker.class::Label}_create create-issue" | 18 | %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "#{@app.issue_tracker.class::Label}_create create-issue" |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | += generate_problem_ical(@problem.notices.order_by(:created_at.asc)) |