Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/billing/invoice/cron_monthly.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
import os

import postmarker
from db import async_session
from db import async_session # TODO(REN-87): Migrate from legacy db module to core.database
from invoice_builder import PERIOD, build
from sqlalchemy import text

client = postmarker.PostmarkClient(server_token=os.environ["POSTMARK_KEY"])


async def main():
async with async_session() as s:
rows = await s.execute("SELECT id,email FROM creators")
rows = await s.execute(text("SELECT id,email FROM creators"))
for r in rows:
url, total = await build(r.id)
client.emails.send(
Expand Down
5 changes: 3 additions & 2 deletions core/billing/invoice/invoice_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import jinja2
import weasyprint
from boto3 import client as s3
from db import async_session
from db import async_session # TODO(REN-87): Migrate from legacy db module to core.database
from sqlalchemy import text

S3 = s3(
"s3",
Expand All @@ -19,7 +20,7 @@
async def build(account_id: str):
async with async_session() as s:
rows = await s.execute(
"""SELECT created_at, delta_usd FROM ledger_entries WHERE account_id=:a AND date_trunc('month', created_at)=date_trunc('month', now()-interval '1 month')""",
text("SELECT created_at, delta_usd FROM ledger_entries WHERE account_id=:a AND date_trunc('month', created_at)=date_trunc('month', now()-interval '1 month')"),
{"a": account_id},
)
items = [
Expand Down
2 changes: 1 addition & 1 deletion core/billing/stripe/ledger/credit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from db import Ledger, async_session
from db import Ledger, async_session # TODO(REN-87): Migrate from legacy db module to core.database


async def credit(creator_id: str, amount: float):
Expand Down
6 changes: 5 additions & 1 deletion core/billing/webhook.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from db import Ledger, UsageEvent, async_session
from db import ( # TODO(REN-87): Migrate from legacy db module to core.database
Ledger,
UsageEvent,
async_session,
)
from fastapi import APIRouter, Request
from sqlalchemy import func, select

Expand Down
Loading