mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-19 00:13:03 +00:00
bug fix: del Depleted
This commit is contained in:
parent
f137b1af76
commit
dc21f41932
4 changed files with 1169 additions and 1080 deletions
|
@ -37,7 +37,7 @@
|
|||
<template slot="content" >
|
||||
{{ i18n "lastOnline" }}: [[ formatLastOnline(client.email) ]]
|
||||
</template>
|
||||
<template v-if="client.enable && isClientOnline(client.email)">
|
||||
<template v-if="client.enable && isClientOnline(client.email) && !isClientDepleted">
|
||||
<a-tag color="green">{{ i18n "online" }}</a-tag>
|
||||
</template>
|
||||
<template v-else>
|
||||
|
@ -49,9 +49,9 @@
|
|||
<a-space direction="horizontal" :size="2">
|
||||
<a-tooltip>
|
||||
<template slot="title">
|
||||
<template v-if="!isClientEnabled(record, client.email)">{{ i18n "depleted" }}</template>
|
||||
<template v-else-if="!client.enable">{{ i18n "disabled" }}</template>
|
||||
<template v-else-if="client.enable && isClientOnline(client.email)">{{ i18n "online" }}</template>
|
||||
<template v-if="isClientDepleted">{{ i18n "depleted" }}</template>
|
||||
<template v-if="!isClientDepleted && !client.enable">{{ i18n "disabled" }}</template>
|
||||
<template v-if="!isClientDepleted && client.enable && isClientOnline(client.email)">{{ i18n "online" }}</template>
|
||||
</template>
|
||||
<a-badge :class="isClientOnline(client.email)? 'online-animation' : ''" :color="client.enable ? statsExpColor(record, client.email) : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"></a-badge>
|
||||
</a-tooltip>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -180,9 +180,9 @@
|
|||
<tr>
|
||||
<td>{{ i18n "status" }}</td>
|
||||
<td>
|
||||
<a-tag v-if="isEnable" color="green">{{ i18n "enabled" }}</a-tag>
|
||||
<a-tag v-else>{{ i18n "disabled" }}</a-tag>
|
||||
<a-tag v-if="!isActive" color="red">{{ i18n "depleted" }}</a-tag>
|
||||
<a-tag v-if="isEnable && isActive && !isDepleted" color="green">{{ i18n "enabled" }}</a-tag>
|
||||
<a-tag v-if="!isEnable && !isDepleted">{{ i18n "disabled" }}</a-tag>
|
||||
<a-tag v-if="isDepleted" color="red">{{ i18n "depleted" }}</a-tag>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="infoModal.clientStats">
|
||||
|
@ -587,6 +587,14 @@
|
|||
}
|
||||
return infoModal.dbInbound.isEnable;
|
||||
},
|
||||
get isDepleted() {
|
||||
const stats = this.infoModal.clientStats;
|
||||
if (!stats) return false;
|
||||
const now = new Date().getTime();
|
||||
const expired = stats.expiryTime > 0 && now >= stats.expiryTime;
|
||||
const exhausted = stats.total > 0 && (stats.up + stats.down) >= stats.total;
|
||||
return expired || exhausted;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
copy(content) {
|
||||
|
|
|
@ -1837,8 +1837,14 @@ func (s *InboundService) DelDepletedClients(id int) (err error) {
|
|||
whereText += "= ?"
|
||||
}
|
||||
|
||||
// Only consider truly depleted clients: expired OR traffic exhausted
|
||||
now := time.Now().Unix() * 1000
|
||||
depletedClients := []xray.ClientTraffic{}
|
||||
err = db.Model(xray.ClientTraffic{}).Where(whereText+" and enable = ?", id, false).Select("inbound_id, GROUP_CONCAT(email) as email").Group("inbound_id").Find(&depletedClients).Error
|
||||
err = db.Model(xray.ClientTraffic{}).
|
||||
Where(whereText+" and ((total > 0 and up + down >= total) or (expiry_time > 0 and expiry_time <= ?))", id, now).
|
||||
Select("inbound_id, GROUP_CONCAT(email) as email").
|
||||
Group("inbound_id").
|
||||
Find(&depletedClients).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1889,7 +1895,8 @@ func (s *InboundService) DelDepletedClients(id int) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
err = tx.Where(whereText+" and enable = ?", id, false).Delete(xray.ClientTraffic{}).Error
|
||||
// Delete stats only for truly depleted clients
|
||||
err = tx.Where(whereText+" and ((total > 0 and up + down >= total) or (expiry_time > 0 and expiry_time <= ?))", id, now).Delete(xray.ClientTraffic{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue