Fix: date grouping for older SQLite versions (#2955)

This commit is contained in:
Vlad Stan 2025-02-12 13:23:38 +02:00 committed by GitHub
parent 15ba3c33a3
commit 16fbfd1c6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View file

@ -104,7 +104,7 @@ class ReleasePaymentInfo(BaseModel):
class PayToEnableInfo(BaseModel): class PayToEnableInfo(BaseModel):
amount: int amount: int = 0
required: bool = False required: bool = False
wallet: Optional[str] = None wallet: Optional[str] = None

View file

@ -1,6 +1,6 @@
import json import json
import time import time
from datetime import datetime, timedelta from datetime import datetime, timedelta, timezone
from typing import Optional from typing import Optional
from bolt11 import Bolt11, MilliSatoshi, Tags from bolt11 import Bolt11, MilliSatoshi, Tags
@ -439,7 +439,7 @@ async def get_payments_daily_stats(
data_in, data_out = await get_daily_stats(filters) data_in, data_out = await get_daily_stats(filters)
balance_total: float = 0 balance_total: float = 0
_none = PaymentDailyStats(date=datetime.now()) _none = PaymentDailyStats(date=datetime.now(timezone.utc))
if len(data_in) == 0: if len(data_in) == 0:
data_in = [_none] data_in = [_none]
if len(data_out) == 0: if len(data_out) == 0:

View file

@ -86,7 +86,12 @@ class Compat:
if self.type in {POSTGRES, COCKROACH}: if self.type in {POSTGRES, COCKROACH}:
return f"date_trunc('{group}', time)" return f"date_trunc('{group}', time)"
elif self.type == SQLITE: elif self.type == SQLITE:
return f"unixepoch(strftime('{sqlite_formats[group]}', time, 'unixepoch'))" return (
"CAST (strftime('%s',datetime(strftime("
f"'{sqlite_formats[group]}'"
", time, 'unixepoch'))) AS INT)"
)
return "<bad grouping>" return "<bad grouping>"
@property @property