Skip to content

Commit

Permalink
fix(get dataset): return a datasetRef, not a dataset!
Browse files Browse the repository at this point in the history
Eventually we will move to returning datasets, not datasetRefs, but we will do that as one refactor!
  • Loading branch information
ramfox committed Mar 1, 2019
1 parent 5ad86c0 commit 6e51a31
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
9 changes: 8 additions & 1 deletion api/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,14 @@ func (h *DatasetHandlers) getHandler(w http.ResponseWriter, r *http.Request) {
util.WriteErrResponse(w, http.StatusInternalServerError, err)
return
}
util.WriteResponse(w, res.Dataset)
ref := repo.DatasetRef{
Peername: res.Dataset.Peername,
ProfileID: profile.ID(res.Dataset.ProfileID),
Name: res.Dataset.Name,
Path: res.Dataset.Path,
Dataset: res.Dataset,
}
util.WriteResponse(w, ref)
}

func (h *DatasetHandlers) diffHandler(w http.ResponseWriter, r *http.Request) {
Expand Down
13 changes: 12 additions & 1 deletion api/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
util "github.com/datatogether/api/apiutil"
"github.com/qri-io/qri/config"
"github.com/qri-io/qri/lib"
"github.com/qri-io/qri/repo"
"github.com/qri-io/qri/repo/profile"
)

// RootHandler bundles handlers that may need to be called
Expand Down Expand Up @@ -62,6 +64,15 @@ func (mh *RootHandler) Handler(w http.ResponseWriter, r *http.Request) {
util.WriteErrResponse(w, http.StatusNotFound, errors.New("cannot find peer dataset"))
return
}
util.WriteResponse(w, res.Dataset)

ref = repo.DatasetRef{
Peername: res.Dataset.Peername,
ProfileID: profile.ID(res.Dataset.ProfileID),
Name: res.Dataset.Name,
Path: res.Dataset.Path,
Dataset: res.Dataset,
}

util.WriteResponse(w, ref)
return
}

0 comments on commit 6e51a31

Please sign in to comment.