Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Alchemy / Heroku compatability #26

Closed
wants to merge 3 commits into from
Closed

Conversation

Sarahtonein
Copy link
Collaborator

Changes

  • Fixed PostgreSQL URL scheme handling for Heroku compatibility
  • Added proper logging for database operations
  • Moved database initialization to a separate module

Fixes error when checking for new creations / update

2:12:52 AM worker.1 |  2025-02-17 02:12:52 - notion_discord_bot - ERROR - Error handling updates: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place? (Background on this error at: https://sqlalche.me/e/20/xd2s)

db_url = os.getenv("DATABASE_URL")
if db_url.startswith("postgres://"):
db_url = db_url.replace("postgres://", "postgresql://", 1)
return db_url
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't we just do:

if os.getenv("DATABASE_URL"):
  return os.getenv("DATABASE_URL").replace("postgres://", "postgresql://", 1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also why did we drop the +psycopg2 part?


await discord_client.start(settings.DISCORD_BOT_TOKEN)

await discord_client.wait_until_ready()
await asyncio.Future()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what purpose does this serve?

from src.infrastructure.config.settings import load_environment, Settings
from src.infrastructure.notion_client.client import NotionClient
from src.infrastructure.discord_client.client import DiscordClient
from src.domain.notion.repositories import SQLNotionRepository
from src.application.notion.notion_service import NotionService
from src.application.discord.discord_service import DiscordService
from src.scripts.init_db import init_db
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would prefer to see this "init_db" functionality added as like a utility or something and then imported into the "scripts/init_db.py" file instead of the other way around

user_model = NotionUserModel(
id=user.id, name=user.name or "Unknown User", avatar_url=user.avatar_url
)
session.add(user_model)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to commit after this?

Copy link
Contributor

@bagelface bagelface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few comments

@Sarahtonein
Copy link
Collaborator Author

Closing PR.

I was encountering an error locally to try and replicate and issue that Bagel was having with deploying the changes to Heroku (staging).

This has since been resolved and as such these changes are unnecessary.

@bagelface bagelface deleted the persistent-state branch February 18, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants