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):
|
class PayToEnableInfo(BaseModel):
|
||||||
amount: int
|
amount: int = 0
|
||||||
required: bool = False
|
required: bool = False
|
||||||
wallet: Optional[str] = None
|
wallet: Optional[str] = None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue