Skip to content

Commit

Permalink
Merge pull request #5 from LEv145/dev
Browse files Browse the repository at this point in the history
v 0.2.1
  • Loading branch information
LEv145 authored May 9, 2022
2 parents b03b602 + 0d72f02 commit 54c51d4
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ version: "3.9"

services:
discoboltalka:
build: ../..
build: ..
image: lev145/discoboltalka
depends_on:
- postgresql
volumes:
- ../../work_dir/config.toml:/usr/app/config.toml
- ../work_dir/production/config.toml:/usr/app/config.toml
restart: unless-stopped

postgresql:
image: postgres:14
environment:
POSTGRES_DB: "discoboltalka"
POSTGRES_USER: "discoboltalka_user"
POSTGRES_PASSWORD: "A4VJ4G1mbwKH"
ports:
- "5432:5432"
volumes:
- ../../work_dir/postgresql_data:/var/lib/postgresql/data
- ../work_dir/production/postgresql_data:/var/lib/postgresql/data
restart: unless-stopped
File renamed without changes.
17 changes: 1 addition & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "discoboltalka"
version = "0.2.0"
version = "0.2.1"
description = "Discord bot for 'Demo Болталка'"
authors = ["lev"]
license = "MIT"
Expand All @@ -13,7 +13,6 @@ aiohttp = "^3.8.1"
SQLAlchemy = "^1.4.36"
asyncpg = "^0.25.0"
sqlalchemy2-stubs = "^0.0.2-alpha.22"
injector = "^0.19.0"

[tool.poetry.dev-dependencies]
mkinit = "^0.3.4"
Expand Down
Empty file added src/discoboltalka/__init__.py
Empty file.
12 changes: 5 additions & 7 deletions src/discoboltalka/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from .abstract_repositories import (
AbstractDialogRepository,
)
from .adapters import (
ErrorEmbed,
context_table,
Expand All @@ -16,17 +13,18 @@
ClientResponseError,
ValidationError,
)
from .repositories import (
DialogRepository,
from .query_apis import (
ABCDialogQueryAPI,
DialogQueryAPI,
)

__all__ = [
"ABCDialogQueryAPI",
"APIError",
"AbstractDialogRepository",
"BoltalkaAPI",
"BoltalkaEvents",
"ClientResponseError",
"DialogRepository",
"DialogQueryAPI",
"ErrorEmbed",
"ValidationError",
"context_table",
Expand Down
5 changes: 0 additions & 5 deletions src/discoboltalka/api/abstract_repositories/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/discoboltalka/api/events/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .boltalka_events import (
from .boltalka import (
BoltalkaEvents,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ClientResponseError,
)
from ..adapters.embeds import ErrorEmbed
from ..abstract_repositories import AbstractDialogRepository
from ..query_apis import ABCDialogQueryAPI


_logger = logging.getLogger(__name__)
Expand All @@ -23,7 +23,7 @@ class BoltalkaEvents():
def __init__(
self,
boltalka_api: BoltalkaAPI,
dialog_repository: AbstractDialogRepository,
dialog_repository: ABCDialogQueryAPI,
channels_for_conversation: list | None = None,
) -> None:
self._boltalka_api = boltalka_api
Expand Down
8 changes: 8 additions & 0 deletions src/discoboltalka/api/query_apis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from .abc import (
ABCDialogQueryAPI,
)
from .impl import (
DialogQueryAPI,
)

__all__ = ["ABCDialogQueryAPI", "DialogQueryAPI"]
5 changes: 5 additions & 0 deletions src/discoboltalka/api/query_apis/abc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .dialog import (
ABCDialogQueryAPI,
)

__all__ = ["ABCDialogQueryAPI"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc


class AbstractDialogRepository(abc.ABC):
class ABCDialogQueryAPI(abc.ABC):
@abc.abstractmethod
async def get_last_contexts(self, user_id: int) -> list[str]:
pass
Expand Down
5 changes: 5 additions & 0 deletions src/discoboltalka/api/query_apis/impl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .dialog import (
DialogQueryAPI,
)

__all__ = ["DialogQueryAPI"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from sqlalchemy.sql import select
from sqlalchemy.dialects.postgresql import insert

from ..adapters import dialog_table, context_table
from ..abstract_repositories import AbstractDialogRepository
from ..abc import ABCDialogQueryAPI
from ...adapters import dialog_table, context_table


if t.TYPE_CHECKING:
Expand All @@ -18,7 +18,7 @@
insert = Insert


class DialogRepository(AbstractDialogRepository):
class DialogQueryAPI(ABCDialogQueryAPI):
def __init__(
self,
session: AsyncSession,
Expand Down
5 changes: 0 additions & 5 deletions src/discoboltalka/api/repositories/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/discoboltalka/application/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from discoboltalka.api import (
BoltalkaAPI,
BoltalkaEvents,
DialogRepository,
DialogQueryAPI,
)

from .providers import (
Expand All @@ -33,7 +33,7 @@ async def async_main() -> None:
message_event_config = config.message_event_config
boltalka_event = BoltalkaEvents(
boltalka_api=boltalka_api,
dialog_repository=DialogRepository(session=postgres_session),
dialog_repository=DialogQueryAPI(session=postgres_session),
channels_for_conversation=message_event_config.channels_for_conversation,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/discoboltalka/api/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sqlalchemy.sql import select, insert

from discoboltalka.api.adapters.orm import sqlalchemy_metadata
from discoboltalka.api.repositories.dialog_repository import (
from discoboltalka.api.query_apis.impl.dialog_repository import (
context_table,
dialog_table,
DialogRepository,
Expand Down

0 comments on commit 54c51d4

Please sign in to comment.