Skip to content

Commit

Permalink
Merge pull request #576 from UnitapApp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
PooyaFekri authored Jul 31, 2024
2 parents 2f3f509 + 3fa2bdb commit ceb080d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
1 change: 0 additions & 1 deletion tokenTap/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,3 @@


UNITAP_PASS_CLAIM_PERCENT = 0.3
UNITAP_PASS_CLAIM_TIME_AVAILABLE = 0.3
28 changes: 16 additions & 12 deletions tokenTap/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import timedelta

from django.core.cache import cache
from django.core.validators import MinValueValidator
from django.db import models
Expand All @@ -9,10 +11,7 @@
from core.utils import calculate_percentage_date
from faucet.constraints import OptimismHasClaimedGasConstraint
from faucet.models import ClaimReceipt
from tokenTap.constants import (
UNITAP_PASS_CLAIM_PERCENT,
UNITAP_PASS_CLAIM_TIME_AVAILABLE,
)
from tokenTap.constants import UNITAP_PASS_CLAIM_PERCENT

from .constraints import (
OnceInALifeTimeVerification,
Expand Down Expand Up @@ -134,15 +133,15 @@ def max_claim_number_for_unitap_pass_user(self):

@property
def remaining_claim_for_unitap_pass_user(self):
remainingupclaims = self.max_claim_number_for_unitap_pass_user
if remainingupclaims is None:
total_claim_number_for_ups = self.max_claim_number_for_unitap_pass_user
if total_claim_number_for_ups is None:
return None
if remainingupclaims == 0:
if total_claim_number_for_ups == 0:
return 0
is_unitap_pass_share_count = self.claims.filter(
is_unitap_pass_share=True
).count()
return remainingupclaims - is_unitap_pass_share_count
return total_claim_number_for_ups - is_unitap_pass_share_count

@property
def remaining_claim_for_normal_user(self):
Expand All @@ -162,10 +161,15 @@ def remaining_claim_for_normal_user(self):

@property
def claim_deadline_for_unitap_pass_user(self):
return calculate_percentage_date(
self.start_at,
self.deadline,
UNITAP_PASS_CLAIM_TIME_AVAILABLE,
dist_duration = self.deadline - self.start_at
if dist_duration > timedelta(days=30):
return self.start_at + timedelta(days=3)
elif dist_duration >= timedelta(days=7) and dist_duration <= timedelta(days=30):
return self.start_at + timedelta(days=2)

return min(
calculate_percentage_date(self.start_at, self.deadline, 0.5),
self.start_at + timedelta(days=1),
)

@property
Expand Down

0 comments on commit ceb080d

Please sign in to comment.