Commit 15a50cf4928960f8c3b70ea49bbbcc0bb98cef6b
1 parent
cf2b8ce4
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Fix api date format
Showing
2 changed files
with
11 additions
and
5 deletions
Show diff stats
lib/api/entities.rb
| 1 | module API | 1 | module API |
| 2 | module Entities | 2 | module Entities |
| 3 | 3 | ||
| 4 | + Grape::Entity.format_with :timestamp do |date| | ||
| 5 | + date.strftime('%Y/%m/%d %H:%M:%S') if date | ||
| 6 | + end | ||
| 7 | + | ||
| 4 | class Image < Grape::Entity | 8 | class Image < Grape::Entity |
| 5 | root 'images', 'image' | 9 | root 'images', 'image' |
| 6 | 10 | ||
| @@ -22,7 +26,8 @@ module API | @@ -22,7 +26,8 @@ module API | ||
| 22 | end | 26 | end |
| 23 | 27 | ||
| 24 | class Profile < Grape::Entity | 28 | class Profile < Grape::Entity |
| 25 | - expose :identifier, :name, :created_at, :id | 29 | + expose :identifier, :name, :id |
| 30 | + expose :created_at, :format_with => :timestamp | ||
| 26 | expose :image, :using => Image | 31 | expose :image, :using => Image |
| 27 | end | 32 | end |
| 28 | 33 | ||
| @@ -42,7 +47,8 @@ module API | @@ -42,7 +47,8 @@ module API | ||
| 42 | 47 | ||
| 43 | class Article < Grape::Entity | 48 | class Article < Grape::Entity |
| 44 | root 'articles', 'article' | 49 | root 'articles', 'article' |
| 45 | - expose :id, :body, :created_at | 50 | + expose :id, :body |
| 51 | + expose :created_at, :format_with => :timestamp | ||
| 46 | expose :title, :documentation => {:type => "String", :desc => "Title of the article"} | 52 | expose :title, :documentation => {:type => "String", :desc => "Title of the article"} |
| 47 | expose :author, :using => Profile | 53 | expose :author, :using => Profile |
| 48 | expose :profile, :using => Profile | 54 | expose :profile, :using => Profile |
| @@ -51,8 +57,8 @@ module API | @@ -51,8 +57,8 @@ module API | ||
| 51 | 57 | ||
| 52 | class Comment < Grape::Entity | 58 | class Comment < Grape::Entity |
| 53 | root 'comments', 'comment' | 59 | root 'comments', 'comment' |
| 54 | - expose :body, :title, :created_at, :id | ||
| 55 | - | 60 | + expose :body, :title, :id |
| 61 | + expose :created_at, :format_with => :timestamp | ||
| 56 | expose :author, :using => Profile | 62 | expose :author, :using => Profile |
| 57 | end | 63 | end |
| 58 | 64 |
lib/api/helpers.rb
| @@ -167,7 +167,7 @@ module API | @@ -167,7 +167,7 @@ module API | ||
| 167 | protected | 167 | protected |
| 168 | 168 | ||
| 169 | def start_log | 169 | def start_log |
| 170 | - logger.info "Started #{request.path}" | 170 | + logger.info "Started #{request.path} #{request.params.except('password')}" |
| 171 | end | 171 | end |
| 172 | def end_log | 172 | def end_log |
| 173 | logger.info "Completed #{request.path}" | 173 | logger.info "Completed #{request.path}" |