Skip to content

Commit

Permalink
fix get full changelog endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasHiltl committed Nov 24, 2024
1 parent f91dfbd commit ab49f53
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions internal/handler/rest/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,30 +259,29 @@ func getFullChangelog(e *env, w http.ResponseWriter, r *http.Request) error {
return errs.NewBadRequest(err)
}

res := apitypes.FullChangelog{
Changelog: changelogToApiType(cl),
}

page, pageSize := handler.ParsePagination(r.URL.Query())
pagination := internal.NewPagination(pageSize, page)

loaded, err := e.loader.LoadAndParseReleaseNotes(r.Context(), cl, pagination)
if err != nil {
return errs.NewBadRequest(err)
}

articles := make([]apitypes.Article, len(loaded.Notes))
for i, a := range loaded.Notes {
content, _ := io.ReadAll(a.Content)
articles[i] = apitypes.Article{
ID: a.Meta.ID,
Title: a.Meta.Title,
Description: a.Meta.Description,
PublishedAt: a.Meta.PublishedAt,
Tags: a.Meta.Tags,
HTMLContent: string(content),
if err == nil {
articles := make([]apitypes.Article, len(loaded.Notes))
for i, a := range loaded.Notes {
content, _ := io.ReadAll(a.Content)
articles[i] = apitypes.Article{
ID: a.Meta.ID,
Title: a.Meta.Title,
Description: a.Meta.Description,
PublishedAt: a.Meta.PublishedAt,
Tags: a.Meta.Tags,
HTMLContent: string(content),
}
}
}
res := apitypes.FullChangelog{
Changelog: changelogToApiType(loaded.CL),
Articles: articles,
HasMoreArticles: loaded.HasMore,
res.Articles = articles
res.HasMoreArticles = loaded.HasMore
}

w.Header().Set("Content-Type", "application/json")
Expand Down

0 comments on commit ab49f53

Please sign in to comment.