Skip to content

Commit

Permalink
feat: add countTotal to datasets response
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Cihelka committed Apr 5, 2023
1 parent bead922 commit e4e4b3a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ func ConfigureDatasetsRouter(e *echo.Group, dldm *core.DeltaDM) {
ds[i].BytesTotal = core.ByteSizes{Raw: tb[0], Padded: tb[1]}

var countReplicated uint64 = 0
var countTotal uint64 = 0
dldm.DB.Raw("select count(*) cr FROM contents c inner join replications r on r.content_comm_p = c.comm_p where r.status = 'SUCCESS' AND dataset_name = ?", d.Name).Row().Scan(&countReplicated)
dldm.DB.Raw("select count(*) cr FROM contents c where dataset_name = ?", d.Name).Row().Scan(&countTotal)

ds[i].CountReplicated = countReplicated
ds[i].CountTotal = countTotal
}

return c.JSON(200, ds)
Expand Down
1 change: 1 addition & 0 deletions core/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type Dataset struct {
BytesReplicated ByteSizes `json:"bytes_replicated,omitempty" gorm:"-"`
BytesTotal ByteSizes `json:"bytes_total,omitempty" gorm:"-"`
CountReplicated uint64 `json:"count_replicated" gorm:"-"`
CountTotal uint64 `json:"count_total" gorm:"-"`
AllowedProviders []Provider `json:"allowed_providers" gorm:"many2many:provider_allowed_datasets;"`
}

Expand Down
2 changes: 2 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ All endpoints (with the exception of `/self-service`) require the `Authorization
"indexed": true,
"contents": null,
"count_replicated": 21, // # of successful replications/storage deals
"count_total": 210, // total # of contents for this dataset
"bytes_replicated": [
198110211431, // Raw bytes (the content itself)
377957122048 // Padded bytes (i.e, filecoin piece)
Expand All @@ -113,6 +114,7 @@ All endpoints (with the exception of `/self-service`) require the `Authorization
"indexed": true,
"contents": null,
"count_replicated": 14, // # of successful replications/storage deals
"count_total": 440, // total # of contents for this dataset
"bytes_replicated": [
198110211431, // Raw bytes (the content itself)
377957122048 // Padded bytes (i.e, filecoin piece)
Expand Down

0 comments on commit e4e4b3a

Please sign in to comment.