Skip to content

Commit

Permalink
Fix download stats (#1256)
Browse files Browse the repository at this point in the history
* fix download stats

* fix typo
  • Loading branch information
Hitenjain14 authored Sep 19, 2023
1 parent d10e14b commit c494c6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func (fsh *StorageHandler) DownloadFile(ctx context.Context, r *http.Request) (i
}

fileDownloadResponse.Data = chunkData
reference.FileBlockDownloaded(ctx, fileref.ID, dr.NumBlocks)
reference.FileBlockDownloaded(ctx, fileref, dr.NumBlocks)
addDailyBlocks(clientID, dr.NumBlocks)
return fileDownloadResponse, nil
}
Expand Down
4 changes: 2 additions & 2 deletions code/go/0chain.net/blobbercore/reference/filestats.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func FileUpdated(ctx context.Context, refID, newRefID int64) {
// }
}

func FileBlockDownloaded(ctx context.Context, refID, blocks int64) {
func FileBlockDownloaded(ctx context.Context, ref *Ref, blocks int64) {
db := datastore.GetStore().GetTransaction(ctx)
db.Model(&Ref{}).Where("id=?", refID).Update("num_of_block_downloads", gorm.Expr("num_of_block_downloads + ?", blocks))
db.Model(ref).Update("num_of_block_downloads", gorm.Expr("num_of_block_downloads + ?", blocks))
}

func GetFileStats(ctx context.Context, ref *Ref) (*FileStats, error) {
Expand Down

0 comments on commit c494c6f

Please sign in to comment.