mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 04:09:40 -06:00
calculate quota stage
This commit is contained in:
@@ -452,10 +452,27 @@ func (g Graph) getDriveQuota(ctx context.Context, space *storageprovider.Storage
|
||||
Total: &total,
|
||||
Used: &used,
|
||||
}
|
||||
state := calculateQuotaState(total, used)
|
||||
qta.State = &state
|
||||
|
||||
return qta, nil
|
||||
}
|
||||
|
||||
func calculateQuotaState(total int64, used int64) (state string) {
|
||||
percent := (float64(used) / float64(total)) * 100
|
||||
|
||||
switch {
|
||||
case percent <= float64(75):
|
||||
return "normal"
|
||||
case percent <= float64(90):
|
||||
return "nearing"
|
||||
case percent <= float64(99):
|
||||
return "critical"
|
||||
default:
|
||||
return "exceeded"
|
||||
}
|
||||
}
|
||||
|
||||
func getQuota(quota *msgraph.Quota, defaultQuota string) *provider.Quota {
|
||||
switch {
|
||||
case quota != nil && quota.Total != nil:
|
||||
@@ -471,5 +488,4 @@ func getQuota(quota *msgraph.Quota, defaultQuota string) *provider.Quota {
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user