Skip to content

Presenters

mongorunway.presentation.presenters ¤

__all__: typing.Sequence[str] = ('show_status', 'show_version', 'show_auditlog_entries') module-attribute ¤

show_auditlog_entries(application, verbose_exc, ascending_date, start=None, end=None, limit=10) ¤

Source code in mongorunway\presentation\presenters.py
def show_auditlog_entries(
    application: applications.MigrationApp,
    verbose_exc: bool,
    ascending_date: bool,
    start: typing.Optional[typing.Sequence[str]] = None,
    end: typing.Optional[typing.Sequence[str]] = None,
    limit: typing.Optional[int] = 10,
) -> None:
    entries_result = use_cases.get_auditlog_entries(
        application,
        start=formatters.format_app_date(application, start),
        end=formatters.format_app_date(application, end),
        limit=limit,
        verbose_exc=verbose_exc,
        ascending_date=ascending_date,
    )

    if entries_result is not use_cases.UseCaseFailed:
        output.print(
            terminaltables.SingleTable(
                [
                    ["Date", "Is Failed", "Transaction Type", "Migration"],
                    *(formatters.format_auditlog_entry(entry) for entry in entries_result),
                ]
            ).table
        )

show_status(application, verbose_exc, pushed_depth=-1) ¤

Source code in mongorunway\presentation\presenters.py
def show_status(
    application: applications.MigrationApp,
    verbose_exc: bool,
    pushed_depth: int = -1,
) -> None:
    status_result = use_cases.get_status(
        application=application,
        verbose_exc=verbose_exc,
        pushed_depth=pushed_depth,
    )

    if status_result is not use_cases.UseCaseFailed:
        all_pushed_successfully, pushed_depth = status_result
        if all_pushed_successfully:
            presentation = f"All migrations applied successfully in depth {pushed_depth!r}"
        else:
            presentation = f"Applying failed in depth {pushed_depth!r}"

        presentation += f" " + (
            f"({application.session.get_current_version()}"
            f" "
            f"of {len(list(application.session.get_all_migration_models()))})"
        )

        output.print_heading(output.HEADING_LEVEL_ONE, output.TOOL_HEADING_NAME)
        output.print_info(presentation)

show_version(application) ¤

Source code in mongorunway\presentation\presenters.py
def show_version(application: applications.MigrationApp) -> None:
    version_result = application.session.get_current_version()

    if version_result is not use_cases.UseCaseFailed:
        presentation = f"Current applied version is {version_result}"
        all_applied_migrations_len = len(list(application.session.get_all_migration_models()))
        presentation += f" " + f"({version_result} of {all_applied_migrations_len})"

        output.print_heading(output.HEADING_LEVEL_ONE, output.TOOL_HEADING_NAME)
        output.print_success(presentation)