Compare commits

..

No commits in common. "a77bc95ce3942ed6c7244f95ba2b6e2a43f3e0b2" and "9425fde4b82df2540497805b4f27f1ff33ecd93f" have entirely different histories.

4 changed files with 20 additions and 22 deletions

View File

@ -1,5 +1,5 @@
[tool.bumpversion] [tool.bumpversion]
current_version = "1.2.11" current_version = "1.2.10"
commit = true commit = true
tag = true tag = true
tag_name = "{new_version}" tag_name = "{new_version}"

View File

@ -1 +1 @@
1.2.11 1.2.10

View File

@ -3,34 +3,34 @@ from typing import List, Dict
def filter_accounts_next_30_days(accounts: List[Dict[str, int]]) -> List[Dict[str, int]]: def filter_accounts_next_30_days(accounts: List[Dict[str, int]]) -> List[Dict[str, int]]:
"""Filter accounts whose expiry date falls within the next 30 days. """Filter accounts whose expiry date falls within the next 30 days.
Args: Args:
accounts (List[Dict[str, int]]): A list of account dictionaries, each containing accounts (List[Dict[str, int]]): A list of account dictionaries, each containing
an 'expiaryDate' key with an epoch timestamp as its value. an 'expiaryDate' key with an epoch timestamp as its value.
Returns: Returns:
List[Dict[str, int]]: A list of accounts expiring within the next 30 days. List[Dict[str, int]]: A list of accounts expiring within the next 30 days.
""" """
now = datetime.now() now = datetime.now()
thirty_days_later = now + timedelta(days=30) thirty_days_later = now + timedelta(days=30)
# Convert current time and 30 days later to epoch timestamps
now_timestamp = int(now.timestamp()) now_timestamp = int(now.timestamp())
thirty_days_later_timestamp = int(thirty_days_later.timestamp()) thirty_days_later_timestamp = int(thirty_days_later.timestamp())
result = [] # Filter accounts with expiryDate within the next 30 days
today = now.date() return [
account for account in accounts
for account in accounts: if now_timestamp <= account['expiaryDate'] < thirty_days_later_timestamp
if now_timestamp <= account['expiaryDate'] < thirty_days_later_timestamp: ]
expiry_date = datetime.fromtimestamp(account['expiaryDate'])
account['expiaryDate_rendered'] = expiry_date.strftime('%d-%m-%Y')
expiry_date_date = expiry_date.date()
account['days_to_expiry'] = (expiry_date_date - today).days
result.append(account)
return result
def filter_accounts_expired(accounts: List[Dict[str, int]]) -> List[Dict[str, int]]: def filter_accounts_expired(accounts: List[Dict[str, int]]) -> List[Dict[str, int]]:
"""Filter accounts whose expiry date has passed. """Filter accounts whose expiry date has passed.
Args: Args:
accounts (List[Dict[str, int]]): A list of account dictionaries, each containing accounts (List[Dict[str, int]]): A list of account dictionaries, each containing
an 'expiaryDate' key with an epoch timestamp as its value. an 'expiaryDate' key with an epoch timestamp as its value.
Returns: Returns:
List[Dict[str, int]]: A list of accounts that have expired. List[Dict[str, int]]: A list of accounts that have expired.
""" """
@ -38,11 +38,9 @@ def filter_accounts_expired(accounts: List[Dict[str, int]]) -> List[Dict[str, in
current_timestamp = int(datetime.now().timestamp()) current_timestamp = int(datetime.now().timestamp())
# Filter accounts where the current date is greater than the expiryDate # Filter accounts where the current date is greater than the expiryDate
expired_accounts = [] expired_accounts = [
for account in accounts: account for account in accounts
if account['expiaryDate'] < current_timestamp: if account['expiaryDate'] < current_timestamp
expiry_date = datetime.fromtimestamp(account['expiaryDate']) ]
account['expiaryDate_rendered'] = expiry_date.strftime('%d-%m-%Y')
expired_accounts.append(account)
return expired_accounts return expired_accounts

View File

@ -23,7 +23,7 @@
<tr> <tr>
<td>{{ account.stream }}</td> <td>{{ account.stream }}</td>
<td>{{ account.username }}</td> <td>{{ account.username }}</td>
<td>{{ account.expiaryDate_rendered }} {% if account.days_to_expiry is defined %}<span style="color: red;">({{ account.days_to_expiry }} days)</span>{% endif %}</td> <td>{{ account.expiaryDate_rendered }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>