support max size

This commit is contained in:
Sotirios Pupakis
2025-09-06 23:45:24 +02:00
parent 3f77524f66
commit 164f80dbb9

View File

@@ -20,8 +20,16 @@ func GetNextToBeIndexed(c *gin.Context) {
checkIndexingTimeout() checkIndexingTimeout()
maxFileSizeMB := c.Query("maxFileSizeMB")
maxSize := 10_000_000
if maxFileSizeMB != "" {
if val, err := strconv.Atoi(maxFileSizeMB); err == nil {
maxSize = val
}
}
var addon models.Addon var addon models.Addon
ret := initializers.DB.Where("to_be_indexed = ?", true).Where("priority_indexing = ?", true).Order("updated_at asc").First(&addon) ret := initializers.DB.Where("to_be_indexed = ?", true).Where("priority_indexing = ?", true).Where("current_version_size <= ?", maxSize).Order("updated_at asc").First(&addon)
if ret.Error == nil { if ret.Error == nil {
addon.IsBeingIndexed = true addon.IsBeingIndexed = true
@@ -37,7 +45,7 @@ func GetNextToBeIndexed(c *gin.Context) {
return return
} }
ret = initializers.DB.Where("to_be_indexed = ?", true).Order("updated_at asc").First(&addon) ret = initializers.DB.Where("to_be_indexed = ?", true).Where("priority_indexing = ?", true).Order("updated_at asc").First(&addon)
if ret.Error != nil && ret.Error != gorm.ErrRecordNotFound { if ret.Error != nil && ret.Error != gorm.ErrRecordNotFound {
c.JSON(500, gin.H{"error": ret.Error.Error()}) c.JSON(500, gin.H{"error": ret.Error.Error()})
return return