Commit b406526ef9529d8b9ef722141c152fcceee38e1a

Authored by Victor Costa
Committed by Rodrigo Souto
1 parent 464426aa

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
@@ -169,7 +169,7 @@ module API @@ -169,7 +169,7 @@ module API
169 protected 169 protected
170 170
171 def start_log 171 def start_log
172 - logger.info "Started #{request.path}" 172 + logger.info "Started #{request.path} #{request.params.except('password')}"
173 end 173 end
174 def end_log 174 def end_log
175 logger.info "Completed #{request.path}" 175 logger.info "Completed #{request.path}"