fix - import stat type in orgquotastat

This commit is contained in:
2025-11-17 11:09:25 +03:30
parent 2a34f1093a
commit ed57517af7
5 changed files with 52 additions and 8 deletions

View File

@@ -14,7 +14,8 @@ class QuotaStatsService:
# ================ origin ================
assigner_stat, _ = OrganizationQuotaStats.objects.get_or_create(
organization=assigner,
quota=quota
quota=quota,
stat_type='distribution'
)
assigner_stat.remaining_amount -= distribution.weight
@@ -24,7 +25,8 @@ class QuotaStatsService:
# ============== destination ================
assigned_stat, _ = OrganizationQuotaStats.objects.get_or_create(
organization=assigned,
quota=quota
quota=quota,
stat_type='distribution'
)
assigned_stat.total_amount += distribution.weight
@@ -51,15 +53,16 @@ class QuotaStatsService:
organization=assigned,
quota=quota
)
# if diff > 0 it is added to destination
assigner_stat.remaining_amount -= diff
assigner_stat.total_distributed += diff
assigner_stat.save()
if assigner_stat.stat_type == 'distribution':
# if diff > 0 it is added to destination
assigner_stat.remaining_amount -= diff
print("distributed : ", assigner_stat.total_distributed)
assigner_stat.total_distributed += diff
print(assigner_stat.total_distributed, diff)
assigner_stat.save()
assigned_stat.total_amount += diff
assigned_stat.remaining_amount += diff
print(assigned_stat.id)
assigned_stat.save()
@staticmethod