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

chore: Remove Server Tasks #3592

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
2 changes: 1 addition & 1 deletion docs/docs/overrides/api.html

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions frontend/layouts/admin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ export default defineComponent({
title: i18n.tc("sidebar.maintenance"),
restricted: true,
},
{
icon: $globals.icons.check,
to: "/admin/background-tasks",
title: i18n.tc("sidebar.background-tasks"),
restricted: true,
},
{
icon: $globals.icons.slotMachine,
to: "/admin/parser",
Expand Down
19 changes: 0 additions & 19 deletions frontend/lib/api/admin/admin-tasks.ts

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/lib/api/client-admin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AdminAboutAPI } from "./admin/admin-about";
import { AdminTaskAPI } from "./admin/admin-tasks";
import { AdminUsersApi } from "./admin/admin-users";
import { AdminGroupsApi } from "./admin/admin-groups";
import { AdminBackupsApi } from "./admin/admin-backups";
Expand All @@ -9,7 +8,6 @@ import { ApiRequestInstance } from "~/lib/api/types/non-generated";

export class AdminAPI {
public about: AdminAboutAPI;
public serverTasks: AdminTaskAPI;
public users: AdminUsersApi;
public groups: AdminGroupsApi;
public backups: AdminBackupsApi;
Expand All @@ -18,7 +16,6 @@ export class AdminAPI {

constructor(requests: ApiRequestInstance) {
this.about = new AdminAboutAPI(requests);
this.serverTasks = new AdminTaskAPI(requests);
this.users = new AdminUsersApi(requests);
this.groups = new AdminGroupsApi(requests);
this.backups = new AdminBackupsApi(requests);
Expand Down
3 changes: 0 additions & 3 deletions frontend/lib/api/client-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { RegisterAPI } from "./user/user-registration";
import { MealPlanAPI } from "./user/group-mealplan";
import { EmailAPI } from "./user/email";
import { BulkActionsAPI } from "./user/recipe-bulk-actions";
import { GroupServerTaskAPI } from "./user/group-tasks";
import { ToolsApi } from "./user/organizer-tools";
import { GroupMigrationApi } from "./user/group-migrations";
import { GroupReportsApi } from "./user/group-reports";
Expand Down Expand Up @@ -46,7 +45,6 @@ export class UserApiClient {
public bulk: BulkActionsAPI;
public groupMigration: GroupMigrationApi;
public groupReports: GroupReportsApi;
public grouperServerTasks: GroupServerTaskAPI;
public tools: ToolsApi;
public shopping: ShoppingApi;
public multiPurposeLabels: MultiPurposeLabelsApi;
Expand All @@ -72,7 +70,6 @@ export class UserApiClient {
this.register = new RegisterAPI(requests);
this.mealplans = new MealPlanAPI(requests);
this.mealplanRules = new MealPlanRulesApi(requests);
this.grouperServerTasks = new GroupServerTaskAPI(requests);

// Group
this.groupMigration = new GroupMigrationApi(requests);
Expand Down
25 changes: 0 additions & 25 deletions frontend/lib/api/types/server.ts

This file was deleted.

13 changes: 0 additions & 13 deletions frontend/lib/api/user/group-tasks.ts

This file was deleted.

87 changes: 0 additions & 87 deletions frontend/pages/admin/background-tasks.vue

This file was deleted.

12 changes: 9 additions & 3 deletions mealie/db/models/group/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@
from ..group.invite_tokens import GroupInviteToken
from ..group.webhooks import GroupWebhooksModel
from ..recipe.category import Category, group_to_categories
from ..server.task import ServerTaskModel
from .cookbook import CookBook
from .mealplan import GroupMealPlan
from .preferences import GroupPreferencesModel

if TYPE_CHECKING:
from ..recipe import IngredientFoodModel, IngredientUnitModel, RecipeModel, Tag, Tool
from ..recipe import (
IngredientFoodModel,
IngredientUnitModel,
RecipeModel,
Tag,
Tool,
)
from ..server.task import ServerTaskModel
from ..users import User
from .events import GroupEventNotifierModel
from .exports import GroupDataExportsModel
Expand Down Expand Up @@ -67,7 +73,7 @@ class Group(SqlAlchemyBase, BaseMixins):
webhooks: Mapped[list[GroupWebhooksModel]] = orm.relationship(GroupWebhooksModel, **common_args)
recipe_actions: Mapped[list["GroupRecipeAction"]] = orm.relationship("GroupRecipeAction", **common_args)
cookbooks: Mapped[list[CookBook]] = orm.relationship(CookBook, **common_args)
server_tasks: Mapped[list[ServerTaskModel]] = orm.relationship(ServerTaskModel, **common_args)
server_tasks: Mapped[list["ServerTaskModel"]] = orm.relationship("ServerTaskModel", **common_args)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did this need to change?
(I don't have a problem with it, just not sure why the change is being made)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah, that's because I removed the line by accident then put it back (and accidentally did it slightly differently). Specifically it's different because of how imports work with SQLAlchemy: I could've put it back how it was, but I also moved the import to typing only (which means it's not actually imported at runtime):

# earlier in the file
if TYPE_CHECKING:
    ...
    from ..server.task import ServerTaskModel

This is a better way of handling imports in this scenario since it's slightly more performant and avoids circular imports (though that's not actually an issue here). In theory we should replace all of our SQLAlchemy imports to do this, but the performance benefit is negligible so it's not worth the effort.


TL;DR it's a totally unnecessary change I did by accident, but I'm inclined to leave it because it's technically better anyway

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or not at all and prod breaks. Cool
#3630

Copy link
Collaborator

Choose a reason for hiding this comment

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

At least we had fun 😅

data_exports: Mapped[list["GroupDataExportsModel"]] = orm.relationship("GroupDataExportsModel", **common_args)
shopping_lists: Mapped[list["ShoppingList"]] = orm.relationship("ShoppingList", **common_args)
group_reports: Mapped[list["ReportModel"]] = orm.relationship("ReportModel", **common_args)
Expand Down
2 changes: 2 additions & 0 deletions mealie/db/models/server/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@


class ServerTaskModel(SqlAlchemyBase, BaseMixins):
# Server Tasks are deprecated, but the table still exists in the database

__tablename__ = "server_tasks"
name: Mapped[str] = mapped_column(String, nullable=False)
completed_date: Mapped[datetime] = mapped_column(DateTime, nullable=True)
Expand Down
6 changes: 0 additions & 6 deletions mealie/repos/repository_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from mealie.db.models.recipe.shared import RecipeShareTokenModel
from mealie.db.models.recipe.tag import Tag
from mealie.db.models.recipe.tool import Tool
from mealie.db.models.server.task import ServerTaskModel
from mealie.db.models.users import LongLiveToken, User
from mealie.db.models.users.password_reset import PasswordResetModel
from mealie.db.models.users.user_to_recipe import UserToRecipe
Expand Down Expand Up @@ -59,7 +58,6 @@
from mealie.schema.recipe.recipe_share_token import RecipeShareToken
from mealie.schema.recipe.recipe_timeline_events import RecipeTimelineEventOut
from mealie.schema.reports.reports import ReportEntryOut, ReportOut
from mealie.schema.server import ServerTask
from mealie.schema.user import GroupInDB, LongLiveTokenInDB, PrivateUser
from mealie.schema.user.user import UserRatingOut
from mealie.schema.user.user_passwords import PrivatePasswordResetToken
Expand Down Expand Up @@ -162,10 +160,6 @@ def tokens_pw_reset(self) -> RepositoryGeneric[PrivatePasswordResetToken, Passwo
# ================================================================
# Group

@cached_property
def server_tasks(self) -> RepositoryGeneric[ServerTask, ServerTaskModel]:
return RepositoryGeneric(self.session, PK_ID, ServerTaskModel, ServerTask)

@cached_property
def groups(self) -> RepositoryGroup:
return RepositoryGroup(self.session, PK_ID, Group, GroupInDB)
Expand Down
2 changes: 0 additions & 2 deletions mealie/routes/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
admin_maintenance,
admin_management_groups,
admin_management_users,
admin_server_tasks,
)

router = AdminAPIRouter(prefix="/admin")
Expand All @@ -17,7 +16,6 @@
router.include_router(admin_management_users.router, tags=["Admin: Manage Users"])
router.include_router(admin_management_groups.router, tags=["Admin: Manage Groups"])
router.include_router(admin_email.router, tags=["Admin: Email"])
router.include_router(admin_server_tasks.router, tags=["Admin: Server Tasks"])
router.include_router(admin_backups.router, tags=["Admin: Backups"])
router.include_router(admin_maintenance.router, tags=["Admin: Maintenance"])
router.include_router(admin_analytics.router, tags=["Admin: Analytics"])
27 changes: 0 additions & 27 deletions mealie/routes/admin/admin_server_tasks.py

This file was deleted.

10 changes: 0 additions & 10 deletions mealie/schema/server/__init__.py

This file was deleted.

50 changes: 0 additions & 50 deletions mealie/schema/server/tasks.py

This file was deleted.

1 change: 0 additions & 1 deletion mealie/services/server_tasks/__init__.py

This file was deleted.

Loading
Loading