From 6e51a3198d25af40b4ad58425ee116b99e681686 Mon Sep 17 00:00:00 2001 From: Kasey Date: Fri, 1 Mar 2019 18:37:41 -0500 Subject: [PATCH 1/2] fix(get dataset): return a datasetRef, not a dataset! Eventually we will move to returning datasets, not datasetRefs, but we will do that as one refactor! --- api/datasets.go | 9 ++++++++- api/root.go | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/api/datasets.go b/api/datasets.go index ac9671148..87744a905 100644 --- a/api/datasets.go +++ b/api/datasets.go @@ -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) { diff --git a/api/root.go b/api/root.go index 997070c26..5669c649c 100644 --- a/api/root.go +++ b/api/root.go @@ -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 @@ -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 } From 3f56dbbdc3263b8729f4b03df18733462faa674a Mon Sep 17 00:00:00 2001 From: Kasey Date: Fri, 1 Mar 2019 18:54:20 -0500 Subject: [PATCH 2/2] tests(api get): fix get handler tests effected by change --- api/testdata/api.snapshot | Bin 172114 -> 172376 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/testdata/api.snapshot b/api/testdata/api.snapshot index 9a3069ae69823a0643a526ca000a37e8a0917aec..ff20959bed9e4b783dd3fcf9f72b49e59d55c188 100755 GIT binary patch delta 79 zcmV-V0I>hkzzW#H3V^f$nCh26JOU<{4buTFm(WN82)B>)0i^<$bov1!m)YF`43`jh l0tc5#-T^k3d|v`nx6StfCj*x^`vEbRpf&<2x6<$dfUhp=AiDqn delta 173 zcmca{i0je;u7)j)GhR)2_@j6%~5RGFfuughQ(n7-x)qv`Z)T_&aN zrQaA68K?KCGucnq)n}5O{_g{0{q$#COhVJ=>ociLU+KwYI$cZx$X)b~QDnNC5R>Ti z8yZYb(~}LD%%-3H$;dVRr2$j^bX#vGrRnnFOmfp3w3sxfuk&V7hH!1PnX0BIbTF|@ ZH<$y|oA8BEVEX+}jGWsaeq=0P4*-~IJ|zGE