From f60d53efe354b3e9ff96f3b20cb228fa509bde77 Mon Sep 17 00:00:00 2001 From: Maksim Sitnikov Date: Tue, 1 Oct 2024 11:55:38 +0300 Subject: [PATCH] Remove sorting entries by updatedAt (#188) --- src/db/models/favorite/index.ts | 4 ---- src/db/models/favorite/scheme.ts | 2 +- src/db/models/navigation/index.ts | 4 ---- src/db/models/navigation/scheme.ts | 2 +- src/services/new/workbook/get-workbook-content.ts | 8 ++------ 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/db/models/favorite/index.ts b/src/db/models/favorite/index.ts index 5d8fc211..6fb6ca28 100644 --- a/src/db/models/favorite/index.ts +++ b/src/db/models/favorite/index.ts @@ -125,10 +125,6 @@ class Favorite extends Model { .modify((builder) => { if (orderBy) { switch (orderBy.field) { - case 'updatedAt': - builder.orderBy('entries.updatedAt', orderBy.direction); - builder.orderBy('entries.entryId'); - break; case 'createdAt': builder.orderBy('entries.createdAt', orderBy.direction); builder.orderBy('entries.entryId'); diff --git a/src/db/models/favorite/scheme.ts b/src/db/models/favorite/scheme.ts index 34ff3fef..008d0eb5 100644 --- a/src/db/models/favorite/scheme.ts +++ b/src/db/models/favorite/scheme.ts @@ -27,7 +27,7 @@ export const validateGetFavorites = compileSchema({ properties: { field: { type: 'string', - enum: ['updatedAt', 'createdAt', 'name'], + enum: ['createdAt', 'name'], }, direction: { type: 'string', diff --git a/src/db/models/navigation/index.ts b/src/db/models/navigation/index.ts index 8fbf6541..0b89a234 100644 --- a/src/db/models/navigation/index.ts +++ b/src/db/models/navigation/index.ts @@ -180,10 +180,6 @@ class Navigation extends Model { .modify((builder) => { if (orderBy) { switch (orderBy.field) { - case 'updatedAt': - builder.orderBy('revisions.updatedAt', orderBy.direction); - builder.orderBy('entries.entryId'); - break; case 'createdAt': builder.orderBy('entries.createdAt', orderBy.direction); builder.orderBy('entries.entryId'); diff --git a/src/db/models/navigation/scheme.ts b/src/db/models/navigation/scheme.ts index c8b2b89f..9bc883c8 100644 --- a/src/db/models/navigation/scheme.ts +++ b/src/db/models/navigation/scheme.ts @@ -44,7 +44,7 @@ export const validateGetEntries = compileSchema({ properties: { field: { type: 'string', - enum: ['updatedAt', 'createdAt', 'name'], + enum: ['createdAt', 'name'], }, direction: { type: 'string', diff --git a/src/services/new/workbook/get-workbook-content.ts b/src/services/new/workbook/get-workbook-content.ts index 369c7266..fb3f56a4 100644 --- a/src/services/new/workbook/get-workbook-content.ts +++ b/src/services/new/workbook/get-workbook-content.ts @@ -47,7 +47,7 @@ const validateArgs = makeSchemaValidator({ properties: { field: { type: 'string', - enum: ['name', 'updatedAt', 'createdAt'], + enum: ['name', 'createdAt'], }, direction: { type: 'string', @@ -71,7 +71,7 @@ export interface GetWorkbookContentArgs { name?: string; }; orderBy?: { - field: 'name' | 'updatedAt' | 'createdAt'; + field: 'name' | 'createdAt'; direction: 'asc' | 'desc'; }; scope?: EntryScope | EntryScope[]; @@ -151,10 +151,6 @@ export const getWorkbookContent = async ( modify: (builder) => { if (orderBy) { switch (orderBy.field) { - case 'updatedAt': - builder.orderBy('revisions.updatedAt', orderBy.direction); - builder.orderBy('entries.entryId'); - break; case 'createdAt': builder.orderBy('entries.createdAt', orderBy.direction); builder.orderBy('entries.entryId');