@@ -57,12 +57,15 @@ func (s *Server) listBranches(w http.ResponseWriter, r *http.Request) {
5757 continue
5858 }
5959
60+ numSnapshots , parentSnapshot := findBranchParent (repo .Snapshots , snapshotDetails .ID , branchEntity .Name )
61+
6062 branchView := models.BranchView {
61- Name : branchEntity .Name ,
62- Parent : findBranchParent (repo .Snapshots , snapshotDetails .ID , branchEntity .Name ),
63- DataStateAt : snapshotDetails .DataStateAt ,
64- SnapshotID : snapshotDetails .ID ,
65- Dataset : snapshotDetails .Dataset ,
63+ Name : branchEntity .Name ,
64+ Parent : parentSnapshot ,
65+ DataStateAt : snapshotDetails .DataStateAt ,
66+ SnapshotID : snapshotDetails .ID ,
67+ Dataset : snapshotDetails .Dataset ,
68+ NumSnapshots : numSnapshots ,
6669 }
6770
6871 if position , ok := branchRegistry [branchEntity .Name ]; ok {
@@ -83,13 +86,16 @@ func (s *Server) listBranches(w http.ResponseWriter, r *http.Request) {
8386 }
8487}
8588
86- func findBranchParent (snapshots map [string ]models.SnapshotDetails , parentID , branch string ) string {
89+ func findBranchParent (snapshots map [string ]models.SnapshotDetails , parentID , branch string ) (int , string ) {
90+ snapshotCounter := 0
91+
8792 for i := len (snapshots ); i > 0 ; i -- {
8893 snapshotPointer := snapshots [parentID ]
94+ snapshotCounter ++
8995
9096 if containsString (snapshotPointer .Root , branch ) {
9197 if len (snapshotPointer .Branch ) > 0 {
92- return snapshotPointer .Branch [0 ]
98+ return snapshotCounter , snapshotPointer .Branch [0 ]
9399 }
94100
95101 break
@@ -102,7 +108,7 @@ func findBranchParent(snapshots map[string]models.SnapshotDetails, parentID, bra
102108 parentID = snapshotPointer .Parent
103109 }
104110
105- return "-"
111+ return snapshotCounter , "-"
106112}
107113
108114func containsString (slice []string , s string ) bool {
0 commit comments