Fix author in posts not working, remove relative times

This commit is contained in:
Morgan Bazalgette 2017-02-16 22:05:55 +01:00
parent bc2100b889
commit 0315dd61d2
No known key found for this signature in database
GPG Key ID: 40D328300D245DA5

View File

@ -20,12 +20,15 @@ type mediumResp struct {
Success bool `json:"success"` Success bool `json:"success"`
Payload struct { Payload struct {
Posts []mediumPost `json:"posts"` Posts []mediumPost `json:"posts"`
References struct {
User map[string]mediumUser
} `json:"references"`
} `json:"payload"` } `json:"payload"`
} }
type mediumPost struct { type mediumPost struct {
ID string `json:"id"` ID string `json:"id"`
Creator mediumUser `json:"creator"` CreatorID string `json:"creatorId"`
Title string `json:"title"` Title string `json:"title"`
CreatedAt int64 `json:"createdAt"` CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"` UpdatedAt int64 `json:"updatedAt"`
@ -41,8 +44,6 @@ type mediumUser struct {
} }
type mediumPostVirtuals struct { type mediumPostVirtuals struct {
CreatedAtRelative string `json:"createdAtRelative"`
UpdatedAtRelative string `json:"updatedAtRelative"`
Snippet string `json:"snippet"` Snippet string `json:"snippet"`
WordCount int `json:"wordCount"` WordCount int `json:"wordCount"`
ReadingTime float64 `json:"readingTime"` ReadingTime float64 `json:"readingTime"`
@ -59,8 +60,6 @@ type blogPost struct {
ImportedURL string `json:"imported_url"` ImportedURL string `json:"imported_url"`
UniqueSlug string `json:"unique_slug"` UniqueSlug string `json:"unique_slug"`
CreatedAtRelative string `json:"created_at_relative"`
UpdatedAtRelative string `json:"updated_at_relative"`
Snippet string `json:"snippet"` Snippet string `json:"snippet"`
WordCount int `json:"word_count"` WordCount int `json:"word_count"`
ReadingTime float64 `json:"reading_time"` ReadingTime float64 `json:"reading_time"`
@ -149,12 +148,11 @@ func BlogPostsGET(md common.MethodData) common.CodeMessager {
p.ImportedURL = mp.ImportedURL p.ImportedURL = mp.ImportedURL
p.UniqueSlug = mp.UniqueSlug p.UniqueSlug = mp.UniqueSlug
p.Creator.UserID = mp.Creator.UserID cr := mResp.Payload.References.User[mp.CreatorID]
p.Creator.Name = mp.Creator.Name p.Creator.UserID = cr.UserID
p.Creator.Username = mp.Creator.Username p.Creator.Name = cr.Name
p.Creator.Username = cr.Username
p.CreatedAtRelative = mp.Virtuals.CreatedAtRelative
p.UpdatedAtRelative = mp.Virtuals.UpdatedAtRelative
p.Snippet = mp.Virtuals.Snippet p.Snippet = mp.Virtuals.Snippet
p.WordCount = mp.Virtuals.WordCount p.WordCount = mp.Virtuals.WordCount
p.ReadingTime = mp.Virtuals.ReadingTime p.ReadingTime = mp.Virtuals.ReadingTime