support max size
This commit is contained in:
@@ -20,8 +20,16 @@ func GetNextToBeIndexed(c *gin.Context) {
|
||||
|
||||
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
|
||||
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 {
|
||||
addon.IsBeingIndexed = true
|
||||
@@ -37,7 +45,7 @@ func GetNextToBeIndexed(c *gin.Context) {
|
||||
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 {
|
||||
c.JSON(500, gin.H{"error": ret.Error.Error()})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user