fix(timer): süre hesaplamasını iyileştir
Torrentların eklenme zamanını kullanarak geçen süreyi daha doğru hesapla ve kural oluşturulma tarihi kontrolünü kaldır.
This commit is contained in:
@@ -35,14 +35,7 @@ export const startTimerWorker = (qbit: QbitClient, intervalMs: number) => {
|
||||
|
||||
for (const torrent of torrents) {
|
||||
const tags = normalizeTags(torrent.tags, torrent.category);
|
||||
const addedOnMs = Number(torrent.added_on ?? 0) * 1000;
|
||||
const matchingRules = rules.filter((rule) => {
|
||||
const ruleCreatedAtMs = Date.parse(rule.createdAt);
|
||||
if (Number.isFinite(ruleCreatedAtMs) && addedOnMs > 0) {
|
||||
if (addedOnMs < ruleCreatedAtMs) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return rule.tags.some((tag) => tags.includes(tag.toLowerCase()));
|
||||
});
|
||||
if (matchingRules.length === 0) {
|
||||
@@ -51,8 +44,13 @@ export const startTimerWorker = (qbit: QbitClient, intervalMs: number) => {
|
||||
const matchingRule = matchingRules.reduce((best, current) =>
|
||||
current.seedLimitSeconds < best.seedLimitSeconds ? current : best
|
||||
);
|
||||
const addedOnMs = Number(torrent.added_on ?? 0) * 1000;
|
||||
const elapsedSeconds =
|
||||
addedOnMs > 0
|
||||
? Math.max(0, (Date.now() - addedOnMs) / 1000)
|
||||
: Number(torrent.seeding_time ?? 0);
|
||||
const seedingSeconds = Number(torrent.seeding_time ?? 0);
|
||||
if (seedingSeconds < matchingRule.seedLimitSeconds) {
|
||||
if (elapsedSeconds < matchingRule.seedLimitSeconds) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user