0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-11-08 17:27:32 -05:00

Fix viewed files number is not right if not all files loaded (#35821)

Fix #35803

---------

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
Lunny Xiao
2025-11-03 13:34:52 -08:00
committed by GitHub
parent d9c0f86de8
commit de26c8acce
4 changed files with 24 additions and 8 deletions

View File

@@ -49,6 +49,19 @@ func init() {
db.RegisterModel(new(ReviewState))
}
func (rs *ReviewState) GetViewedFileCount() int {
if len(rs.UpdatedFiles) == 0 {
return 0
}
var numViewedFiles int
for _, state := range rs.UpdatedFiles {
if state == Viewed {
numViewedFiles++
}
}
return numViewedFiles
}
// GetReviewState returns the ReviewState with all given values prefilled, whether or not it exists in the database.
// If the review didn't exist before in the database, it won't afterwards either.
// The returned boolean shows whether the review exists in the database