Skip to content

Commit

Permalink
refactor(render): remove limit, offset, all parmeters
Browse files Browse the repository at this point in the history
No longer needed. Instead templates specify which components of a dataset they need

BREAKING CHANGE:
qri render limit, offset, all parameters have been removed
  • Loading branch information
b5 committed Apr 3, 2019
1 parent ad296c2 commit 165abce
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 19 deletions.
4 changes: 0 additions & 4 deletions api/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ func (h *RenderHandlers) RenderHandler(w http.ResponseWriter, r *http.Request) {
p := &lib.RenderParams{
Ref: HTTPPathToQriPath(r.URL.Path[len("/render"):]),
TemplateFormat: "html",
// TODO - parameterize
All: true,
Limit: 0,
Offset: 0,
}

data := []byte{}
Expand Down
2 changes: 1 addition & 1 deletion base/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func AddDefaultViz(ds *dataset.Dataset) {
}

// Render executes a template for a dataset, returning a slice of HTML
func Render(r repo.Repo, ref repo.DatasetRef, tmplData []byte, limit, offset int, all bool) ([]byte, error) {
func Render(r repo.Repo, ref repo.DatasetRef, tmplData []byte) ([]byte, error) {
const tmplName = "template"

store := r.Store()
Expand Down
3 changes: 1 addition & 2 deletions base/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ func TestRender(t *testing.T) {
r := newTestRepo(t)
ref := addCitiesDataset(t, r)

_, err := Render(r, ref, nil, 0, 0, true)
_, err := Render(r, ref, nil)
if err != nil {
panic(err)
t.Error(err.Error())
}

Expand Down
9 changes: 0 additions & 9 deletions cmd/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ provided, Qri will render the dataset with a default template.`,

cmd.Flags().StringVarP(&o.Template, "template", "t", "", "path to template file")
cmd.Flags().StringVarP(&o.Output, "output", "o", "", "path to write output file")
cmd.Flags().BoolVarP(&o.All, "all", "a", false, "read all dataset entries (overrides limit, offest)")
cmd.Flags().IntVarP(&o.Limit, "limit", "l", 50, "max number of records to read")
cmd.Flags().IntVarP(&o.Offset, "offset", "s", 0, "number of records to skip")

return cmd
}
Expand All @@ -57,9 +54,6 @@ type RenderOptions struct {
Ref string
Template string
Output string
All bool
Limit int
Offset int

RenderRequests *lib.RenderRequests
}
Expand Down Expand Up @@ -88,9 +82,6 @@ func (o *RenderOptions) Run() (err error) {
Ref: o.Ref,
Template: template,
TemplateFormat: "html",
All: o.All,
Limit: o.Limit,
Offset: o.Offset,
}

res := []byte{}
Expand Down
4 changes: 1 addition & 3 deletions lib/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ type RenderParams struct {
Ref string
Template []byte
TemplateFormat string
All bool
Limit, Offset int
}

// Render executes a template against a template
Expand All @@ -61,6 +59,6 @@ func (r *RenderRequests) Render(p *RenderParams, res *[]byte) (err error) {
return err
}

*res, err = base.Render(r.repo, ref, p.Template, p.Limit, p.Offset, p.All)
*res, err = base.Render(r.repo, ref, p.Template)
return err
}

0 comments on commit 165abce

Please sign in to comment.