Commit a87d750a46ec888f0ae8361629077ef810907db1

Authored by Harro
1 parent 826ee340
Exists in master and in 1 other branch production

changed names and logic of should_keep? to match kb article http://help.airbrake…

….io/kb/ios/app-versions
app/controllers/notices_controller.rb
... ... @@ -11,7 +11,6 @@ class NoticesController < ApplicationController
11 11 report = ErrorReport.new(notice_params)
12 12  
13 13 if report.valid?
14   -
15 14 if report.should_keep?
16 15 report.generate_notice!
17 16 api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml|
... ... @@ -19,9 +18,8 @@ class NoticesController < ApplicationController
19 18 end
20 19 render :xml => api_xml
21 20 else
22   - render :nothing => true
  21 + render :xml => "Notice for old app version ignored"
23 22 end
24   -
25 23 else
26 24 render :text => "Your API key is unknown", :status => 422
27 25 end
... ...
app/models/app.rb
... ... @@ -9,7 +9,7 @@ class App
9 9 field :bitbucket_repo
10 10 field :asset_host
11 11 field :repository_branch
12   - field :min_app_version
  12 + field :current_app_version
13 13 field :resolve_errs_on_deploy, :type => Boolean, :default => false
14 14 field :notify_all_users, :type => Boolean, :default => false
15 15 field :notify_on_errs, :type => Boolean, :default => true
... ...
app/models/error_report.rb
... ... @@ -73,27 +73,12 @@ class ErrorReport
73 73 end
74 74  
75 75 def should_keep?
76   -
77 76 app_version = server_environment['app-version'] || ''
78   -
79   - if self.app.min_app_version.present?
80   -
81   - if app_version.length > 0
82   -
83   - if Gem::Version.new(app_version) >= Gem::Version.new(self.app.min_app_version)
84   - true
85   - else
86   - false
87   - end
88   -
89   - else
90   - true
91   - end
92   -
93   - else
94   - true
95   - end
96   -
  77 + if self.app.current_app_version.present? && ( app_version.length <= 0 || Gem::Version.new(app_version) < Gem::Version.new(self.app.current_app_version) )
  78 + false
  79 + else
  80 + true
  81 + end
97 82 end
98 83  
99 84 private
... ...
app/views/apps/_fields.html.haml
... ... @@ -23,9 +23,9 @@
23 23 %em Used to generate links for JavaScript errors
24 24 = f.text_field :asset_host, :placeholder => "e.g. https://assets.example.com"
25 25 %div
26   - = f.label :min_app_version
27   - %em Use with mobile apps to drop errors from old versions that have already been fixed
28   - = f.text_field :min_app_version, :placeholder => "e.g. 2.0.1 from the Bundle Identifier on an iOS app"
  26 + = f.label :current_app_version, 'Latest App Version'
  27 + %em Mobile apps can set this to ignore any error below this version. ie: 1.4.3
  28 + = f.text_field :current_app_version, :placeholder => "e.g. 2.0.1 from the Bundle Identifier on an iOS app"
29 29 %fieldset
30 30 %legend Notifications
31 31 %div.checkbox
... ...
app/views/apps/show.html.haml
... ... @@ -2,9 +2,9 @@
2 2 - content_for :head do
3 3 = auto_discovery_link_tag :atom, app_path(app, User.token_authentication_key => current_user.authentication_token, :format => "atom"), :title => t('.atom_title', :name => app.name, :host => request.host)
4 4 - content_for :meta do
5   - - if app.min_app_version.present?
6   - %strong="Min App Version:"
7   - = app.min_app_version
  5 + - if app.current_app_version.present?
  6 + %strong="Latest App Version:"
  7 + = app.current_app_version
8 8 %strong=t('.errors_caught')
9 9 = app.problems.count
10 10 %strong=t('.deploy_count')
... ...
db/migrate/20131206152837_add_min_app_version_to_apps.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +class AddMinAppVersionToApps < Mongoid::Migration
  2 + def change
  3 + add_column :apps, :current_app_version, :string
  4 + end
  5 +end
0 6 \ No newline at end of file
... ...