Skip to content

Commit

Permalink
refactor: move modules news and pages into the portal module
Browse files Browse the repository at this point in the history
  • Loading branch information
fbraem committed Sep 21, 2023
1 parent d9a3fc7 commit e7a7790
Show file tree
Hide file tree
Showing 35 changed files with 55 additions and 58 deletions.
4 changes: 2 additions & 2 deletions backend/src/kwai/api/v1/portal/endpoints/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from kwai.api.v1.portal.schemas.story import PortalStoryResource
from kwai.core.db.database import Database
from kwai.core.json_api import Meta, PaginationModel
from kwai.modules.news.get_stories import GetStories, GetStoriesCommand
from kwai.modules.news.stories.story_db_repository import StoryDbRepository
from kwai.modules.portal.get_stories import GetStories, GetStoriesCommand
from kwai.modules.portal.stories.story_db_repository import StoryDbRepository

router = APIRouter()

Expand Down
2 changes: 1 addition & 1 deletion backend/src/kwai/api/v1/portal/schemas/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from kwai.api.converter import MarkdownConverter
from kwai.core import json_api
from kwai.modules.news.stories.story import Application, StoryEntity
from kwai.modules.portal.stories.story import Application, StoryEntity


@json_api.resource(type_="applications")
Expand Down
1 change: 0 additions & 1 deletion backend/src/kwai/modules/news/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion backend/src/kwai/modules/page/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Module for the use case "Get Page"."""
from dataclasses import dataclass

from kwai.modules.page.pages.page import PageEntity, PageIdentifier
from kwai.modules.page.pages.page_repository import PageRepository
from kwai.modules.portal.pages.page import PageEntity, PageIdentifier
from kwai.modules.portal.pages.page_repository import PageRepository


@dataclass(kw_only=True, frozen=True, slots=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import dataclass

from kwai.core.domain.use_case import UseCaseBrowseResult
from kwai.modules.page.pages.page_repository import PageRepository
from kwai.modules.portal.pages.page_repository import PageRepository


@dataclass(kw_only=True, frozen=True, slots=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from kwai.core.domain.use_case import UseCaseBrowseResult
from kwai.core.domain.value_objects.unique_id import UniqueId
from kwai.modules.news.stories.story_repository import StoryRepository
from kwai.modules.portal.stories.story_repository import StoryRepository


@dataclass(kw_only=True, frozen=True, slots=True)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from kwai.core.db.database_query import DatabaseQuery
from kwai.core.db.rows import OwnersTable
from kwai.core.domain.value_objects.unique_id import UniqueId
from kwai.modules.page.pages.page import PageIdentifier
from kwai.modules.page.pages.page_query import PageQuery
from kwai.modules.page.pages.page_tables import (
from kwai.modules.portal.pages.page import PageIdentifier
from kwai.modules.portal.pages.page_query import PageQuery
from kwai.modules.portal.pages.page_tables import (
ApplicationsTable,
PageContentsTable,
PagesTable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from kwai.core.db.rows import OwnersTable
from kwai.core.domain.entity import Entity
from kwai.core.functions import async_groupby
from kwai.modules.page.pages.page import PageEntity, PageIdentifier
from kwai.modules.page.pages.page_db_query import PageDbQuery
from kwai.modules.page.pages.page_query import PageQuery
from kwai.modules.page.pages.page_repository import (
from kwai.modules.portal.pages.page import PageEntity, PageIdentifier
from kwai.modules.portal.pages.page_db_query import PageDbQuery
from kwai.modules.portal.pages.page_query import PageQuery
from kwai.modules.portal.pages.page_repository import (
PageNotFoundException,
PageRepository,
)
from kwai.modules.page.pages.page_tables import (
from kwai.modules.portal.pages.page_tables import (
ApplicationsTable,
PageContentRow,
PageContentsTable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from kwai.core.domain.repository.query import Query
from kwai.core.domain.value_objects.unique_id import UniqueId
from kwai.modules.page.pages.page import PageIdentifier
from kwai.modules.portal.pages.page import PageIdentifier


class PageQuery(Query):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from abc import ABC, abstractmethod
from typing import AsyncIterator

from kwai.modules.page.pages.page import PageEntity, PageIdentifier
from kwai.modules.page.pages.page_query import PageQuery
from kwai.modules.portal.pages.page import PageEntity, PageIdentifier
from kwai.modules.portal.pages.page_query import PageQuery


class PageNotFoundException(Exception):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from kwai.core.domain.value_objects.local_timestamp import LocalTimestamp
from kwai.core.domain.value_objects.text import LocaleText
from kwai.core.domain.value_objects.traceable_time import TraceableTime
from kwai.modules.page.pages.page import Application, PageEntity, PageIdentifier
from kwai.modules.portal.pages.page import Application, PageEntity, PageIdentifier


@dataclass(kw_only=True, frozen=True, slots=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from kwai.core.db.database_query import DatabaseQuery
from kwai.core.db.rows import OwnersTable
from kwai.core.domain.value_objects.unique_id import UniqueId
from kwai.modules.news.stories.story import StoryIdentifier
from kwai.modules.news.stories.story_query import StoryQuery
from kwai.modules.news.stories.story_tables import (
from kwai.modules.portal.stories.story import StoryIdentifier
from kwai.modules.portal.stories.story_query import StoryQuery
from kwai.modules.portal.stories.story_tables import (
ApplicationsTable,
StoriesTable,
StoryContentsTable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from kwai.core.db.database import Database
from kwai.core.db.rows import OwnersTable
from kwai.core.domain.entity import Entity
from kwai.modules.news.stories.story import StoryEntity, StoryIdentifier
from kwai.modules.news.stories.story_db_query import StoryDbQuery
from kwai.modules.news.stories.story_query import StoryQuery
from kwai.modules.news.stories.story_repository import (
from kwai.modules.portal.stories.story import StoryEntity, StoryIdentifier
from kwai.modules.portal.stories.story_db_query import StoryDbQuery
from kwai.modules.portal.stories.story_query import StoryQuery
from kwai.modules.portal.stories.story_repository import (
StoryNotFoundException,
StoryRepository,
)
from kwai.modules.news.stories.story_tables import (
from kwai.modules.portal.stories.story_tables import (
ApplicationsTable,
StoriesTable,
StoryContentRow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from kwai.core.domain.repository.query import Query
from kwai.core.domain.value_objects.unique_id import UniqueId
from kwai.modules.news.stories.story import StoryIdentifier
from kwai.modules.portal.stories.story import StoryIdentifier


class StoryQuery(Query):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from abc import ABC, abstractmethod
from typing import AsyncIterator

from kwai.modules.news.stories.story import StoryEntity, StoryIdentifier
from kwai.modules.news.stories.story_query import StoryQuery
from kwai.modules.portal.stories.story import StoryEntity, StoryIdentifier
from kwai.modules.portal.stories.story_query import StoryQuery


class StoryNotFoundException(Exception):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from kwai.core.domain.value_objects.period import Period
from kwai.core.domain.value_objects.text import LocaleText
from kwai.core.domain.value_objects.traceable_time import TraceableTime
from kwai.modules.news.stories.story import (
from kwai.modules.portal.stories.story import (
Application,
Promotion,
StoryEntity,
Expand Down
1 change: 0 additions & 1 deletion backend/src/tests/modules/news/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion backend/src/tests/modules/page/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from kwai.core.db.database import Database
from kwai.core.domain.value_objects.owner import Owner
from kwai.core.domain.value_objects.text import DocumentFormat, Locale, LocaleText
from kwai.modules.page.pages.page import Application, PageEntity
from kwai.modules.page.pages.page_db_repository import PageDbRepository
from kwai.modules.page.pages.page_repository import PageRepository
from kwai.modules.portal.applications.application import ApplicationEntity
from kwai.modules.portal.applications.application_db_repository import (
ApplicationDbRepository,
)
from kwai.modules.portal.pages.page import Application, PageEntity
from kwai.modules.portal.pages.page_db_repository import PageDbRepository
from kwai.modules.portal.pages.page_repository import PageRepository


@pytest.fixture(scope="module")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest

from kwai.core.db.database import Database
from kwai.modules.page.pages.page_db_query import PageDbQuery
from kwai.modules.page.pages.page_query import PageQuery
from kwai.modules.portal.pages.page_db_query import PageDbQuery
from kwai.modules.portal.pages.page_query import PageQuery


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Module for testing the page database repository."""

from kwai.core.domain.entity import Entity
from kwai.modules.page.pages.page import PageEntity
from kwai.modules.page.pages.page_repository import PageRepository
from kwai.modules.portal.pages.page import PageEntity
from kwai.modules.portal.pages.page_repository import PageRepository


async def test_create(repo: PageRepository, saved_page: PageEntity):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import pytest

from kwai.core.db.database import Database
from kwai.modules.news.stories.story import Application
from kwai.modules.portal.applications.application import ApplicationEntity
from kwai.modules.portal.applications.application_db_repository import (
ApplicationDbRepository,
)
from kwai.modules.portal.stories.story import Application


@pytest.fixture(scope="module")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from kwai.core.db.database import Database
from kwai.modules.news.stories.story_db_query import StoryDbQuery
from kwai.modules.portal.stories.story_db_query import StoryDbQuery

pytestmark = pytest.mark.db

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from kwai.core.db.database import Database
from kwai.core.domain.value_objects.owner import Owner
from kwai.core.domain.value_objects.text import DocumentFormat, Locale, LocaleText
from kwai.modules.news.stories.story import (
from kwai.modules.portal.stories.story import (
Application,
StoryEntity,
)
from kwai.modules.news.stories.story_db_repository import StoryDbRepository
from kwai.modules.news.stories.story_repository import (
from kwai.modules.portal.stories.story_db_repository import StoryDbRepository
from kwai.modules.portal.stories.story_repository import (
StoryNotFoundException,
StoryRepository,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Module for testing the use case "Get Page"."""
from kwai.modules.page.get_page import GetPage, GetPageCommand
from kwai.modules.page.pages.page import PageEntity
from kwai.modules.page.pages.page_repository import PageRepository
from kwai.modules.portal.get_page import GetPage, GetPageCommand
from kwai.modules.portal.pages.page import PageEntity
from kwai.modules.portal.pages.page_repository import PageRepository


async def test_get_page(repo: PageRepository, saved_page: PageEntity):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Module for testing the use case "Get Pages"."""

from kwai.modules.page.get_pages import GetPages, GetPagesCommand
from kwai.modules.page.pages.page import PageEntity
from kwai.modules.page.pages.page_repository import PageRepository
from kwai.modules.portal.get_pages import GetPages, GetPagesCommand
from kwai.modules.portal.pages.page import PageEntity
from kwai.modules.portal.pages.page_repository import PageRepository


async def test_get_pages(repo: PageRepository, saved_page: PageEntity):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import pytest

from kwai.core.db.database import Database
from kwai.modules.news.get_stories import GetStories, GetStoriesCommand
from kwai.modules.news.stories.story_db_repository import StoryDbRepository
from kwai.modules.news.stories.story_repository import StoryRepository
from kwai.modules.portal.get_stories import GetStories, GetStoriesCommand
from kwai.modules.portal.stories.story_db_repository import StoryDbRepository
from kwai.modules.portal.stories.story_repository import StoryRepository

pytestmark = pytest.mark.db

Expand Down
5 changes: 3 additions & 2 deletions frontend/packages/kwai-date/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import customParseFormat from 'dayjs/plugin/customParseFormat.js';
// Set the locale
import 'dayjs/locale/en.js';
import 'dayjs/locale/nl.js';

dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(localizedFormat);
Expand Down Expand Up @@ -66,8 +67,8 @@ export function createDatetime(value?: string, fmt: string = 'YYYY-MM-DD HH:mm:s
return createDate(value, fmt);
}

export function createDateTimeFromUTC(value: string, timezone: string, fmt: string = 'YYYY-MM-DD HH:mm:ss'): Readonly<DateType> {
return wrapDayjs(dayjs.utc(value, fmt).tz(timezone));
export function createDateTimeFromUTC(value: string, fmt: string = 'YYYY-MM-DD HH:mm:ss'): Readonly<DateType> {
return wrapDayjs(dayjs.utc(value, fmt).tz());
}

export function now(): Readonly<DateType> {
Expand Down

0 comments on commit e7a7790

Please sign in to comment.