diff options
author | Peter Leitzen <pleitzen@gitlab.com> | 2018-12-12 16:35:29 +0100 |
---|---|---|
committer | Peter Leitzen <pleitzen@gitlab.com> | 2019-01-02 19:41:51 +0100 |
commit | 4cc5483af97fe8411e167815dde7dcc5bedcf5e8 (patch) | |
tree | c552307be346751a718e6c51c67f2a90b4dd7609 | |
parent | 7815a6f3ca3517de0b2df623334d22eda9967566 (diff) | |
download | gitlab-ce-4cc5483af97fe8411e167815dde7dcc5bedcf5e8.tar.gz |
Implement error model
-rw-r--r-- | app/controllers/projects/error_tracking_controller.rb | 93 | ||||
-rw-r--r-- | app/models/error_tracking/error.rb | 10 |
2 files changed, 59 insertions, 44 deletions
diff --git a/app/controllers/projects/error_tracking_controller.rb b/app/controllers/projects/error_tracking_controller.rb index 39a21a4d441..39d3c02d853 100644 --- a/app/controllers/projects/error_tracking_controller.rb +++ b/app/controllers/projects/error_tracking_controller.rb @@ -7,55 +7,60 @@ class Projects::ErrorTrackingController < Projects::ApplicationController end def index - render json: [ + render json: query_errors + end + + private + + def query_errors + [ { - "id": 2, - "first_seen": "2018-11-06T21:19:56Z", - "last_seen": "2018-11-06T21:19:56Z", - "type": "ApiException", - "message": "Authentication failed, token expired!", - "culprit": "io.sentry.example.ApiRequest in perform", - "count": 1, - "external_url": "https://sentry.io/the-interstellar-jurisdiction/pump-station/issues/2/", - "project": { - "id": "2", - "name": "Pump Station", - "slug": "pump-station" - }, - "short_id": "PUMP-STATION-2", - "status": "unresolved", - "status_details": {}, - "title": "ApiException: Authentication failed, token expired!", - "type": "error", - "user_count": 0 + "id": 2, + "first_seen": "2018-11-06T21:19:56Z", + "last_seen": "2018-11-06T21:19:56Z", + "message": "Authentication failed, token expired!", + "culprit": "io.sentry.example.ApiRequest in perform", + "count": 1, + "external_url": "https://sentry.io/the-interstellar-jurisdiction/pump-station/issues/2/", + "project": { + "id": "2", + "name": "Pump Station", + "slug": "pump-station" + }, + "short_id": "PUMP-STATION-2", + "status": "unresolved", + "title": "ApiException: Authentication failed, token expired!", + "type": "error", + "user_count": 0 }, { - "id": 3, - "first_seen": "2018-10-06T21:19:56Z", - "last_seen": "2018-11-06T21:19:56Z", - "type": "BigError", - "message": "All the things failed.", - "culprit": "system.tasks.do.things", - "count": 3, - "external_url": "https://sentry.io/the-interstellar-jurisdiction/pump-station/issues/3/", - "project": { - "id": "2", - "name": "Pump Station", - "slug": "pump-station" - }, - "short_id": "PUMP-STATION-3", - "status": "unresolved", - "status_details": {}, - "title": "BigError: All the things failed.", - "type": "error", - "user_count": 0 - }, - ] - + "id": 3, + "first_seen": "2018-10-06T21:19:56Z", + "last_seen": "2018-11-06T21:19:56Z", + "message": "All the things failed.", + "culprit": "system.tasks.do.things", + "count": 3, + "external_url": "https://sentry.io/the-interstellar-jurisdiction/pump-station/issues/3/", + "project": { + "id": "2", + "name": "Pump Station", + "slug": "pump-station" + }, + "short_id": "PUMP-STATION-3", + "status": "unresolved", + "title": "BigError: All the things failed.", + "type": "error", + "user_count": 0 + } + ].map do |json| + project = json.delete(:project) + json[:project_id] = project.fetch(:id) + json[:project_name] = project.fetch(:name) + json[:project_slug] = project.fetch(:slug) + ErrorTracking::Error.new(json) + end end - private - def check_feature_flag! render_404 unless Feature.enabled?(:error_tracking, project) end diff --git a/app/models/error_tracking/error.rb b/app/models/error_tracking/error.rb new file mode 100644 index 00000000000..ff40e73fb90 --- /dev/null +++ b/app/models/error_tracking/error.rb @@ -0,0 +1,10 @@ +module ErrorTracking + class Error + include ActiveModel::Model + + attr_accessor :id, :title, :type, :user_count, :count, + :first_seen, :last_seen, :message, :culprit, + :external_url, :project_id, :project_name, :project_slug, + :short_id, :status + end +end |