mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-03-13 03:22:36 +01:00
Fix: date grouping for older SQLite versions (#2955)
This commit is contained in:
parent
15ba3c33a3
commit
16fbfd1c6f
3 changed files with 9 additions and 4 deletions
|
@ -104,7 +104,7 @@ class ReleasePaymentInfo(BaseModel):
|
|||
|
||||
|
||||
class PayToEnableInfo(BaseModel):
|
||||
amount: int
|
||||
amount: int = 0
|
||||
required: bool = False
|
||||
wallet: Optional[str] = None
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Optional
|
||||
|
||||
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)
|
||||
balance_total: float = 0
|
||||
|
||||
_none = PaymentDailyStats(date=datetime.now())
|
||||
_none = PaymentDailyStats(date=datetime.now(timezone.utc))
|
||||
if len(data_in) == 0:
|
||||
data_in = [_none]
|
||||
if len(data_out) == 0:
|
||||
|
|
|
@ -86,7 +86,12 @@ class Compat:
|
|||
if self.type in {POSTGRES, COCKROACH}:
|
||||
return f"date_trunc('{group}', time)"
|
||||
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>"
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Reference in a new issue