Revert "[ENG-1004] Add offset pagination capability to search queries… (#1254)

Revert "[ENG-1004] Add offset pagination capability to search queries (#1251)"

This reverts commit a5a25b1439.
This commit is contained in:
Jamie Pine
2023-08-26 14:19:01 -07:00
committed by GitHub
parent a5a25b1439
commit 0def8fb048
4 changed files with 15 additions and 56 deletions

View File

@@ -357,13 +357,6 @@ pub fn mount() -> AlphaRouter<Ctx> {
)
})
.procedure("paths", {
#[derive(Deserialize, Type, Debug)]
#[serde(rename_all = "camelCase")]
enum FilePathPagination {
Cursor { pub_id: file_path::pub_id::Type },
Offset(i32),
}
#[derive(Deserialize, Type, Debug)]
#[serde(rename_all = "camelCase")]
struct FilePathSearchArgs {
@@ -372,7 +365,7 @@ pub fn mount() -> AlphaRouter<Ctx> {
#[specta(optional)]
order: Option<FilePathSearchOrdering>,
#[specta(optional)]
pagination: Option<FilePathPagination>,
cursor: Option<Vec<u8>>,
#[serde(default)]
filter: FilePathFilterArgs,
#[serde(default = "default_group_directories")]
@@ -388,7 +381,7 @@ pub fn mount() -> AlphaRouter<Ctx> {
FilePathSearchArgs {
take,
order,
pagination,
cursor,
filter,
group_directories,
}| async move {
@@ -411,13 +404,8 @@ pub fn mount() -> AlphaRouter<Ctx> {
query = query.order_by(order.into_param());
}
if let Some(pagination) = pagination {
match pagination {
FilePathPagination::Cursor { pub_id } => {
query = query.cursor(file_path::pub_id::equals(pub_id));
}
FilePathPagination::Offset(offset) => query = query.skip(offset as i64),
}
if let Some(cursor) = cursor {
query = query.cursor(file_path::pub_id::equals(cursor));
}
let (file_paths, cursor) = {
@@ -478,13 +466,6 @@ pub fn mount() -> AlphaRouter<Ctx> {
})
})
.procedure("objects", {
#[derive(Deserialize, Type, Debug)]
#[serde(rename_all = "camelCase")]
enum ObjectPagination {
Cursor { pub_id: object::pub_id::Type },
Offset(i32),
}
#[derive(Deserialize, Type, Debug)]
#[serde(rename_all = "camelCase")]
struct ObjectSearchArgs {
@@ -493,7 +474,7 @@ pub fn mount() -> AlphaRouter<Ctx> {
#[specta(optional)]
order: Option<ObjectSearchOrdering>,
#[specta(optional)]
pagination: Option<ObjectPagination>,
cursor: Option<Vec<u8>>,
#[serde(default)]
filter: ObjectFilterArgs,
}
@@ -503,7 +484,7 @@ pub fn mount() -> AlphaRouter<Ctx> {
ObjectSearchArgs {
take,
order,
pagination,
cursor,
filter,
}| async move {
let Library { db, .. } = library.as_ref();
@@ -519,15 +500,8 @@ pub fn mount() -> AlphaRouter<Ctx> {
query = query.order_by(order.into_param());
}
if let Some(pagination) = pagination {
match pagination {
ObjectPagination::Cursor { pub_id } => {
query = query.cursor(object::pub_id::equals(pub_id));
}
ObjectPagination::Offset(offset) => {
query = query.skip(offset as i64);
}
}
if let Some(cursor) = cursor {
query = query.cursor(object::pub_id::equals(cursor));
}
let (objects, cursor) = {

View File

@@ -178,11 +178,7 @@ const useItems = ({
'search.paths',
{
...queryKey[1].arg,
pagination: {
cursor: {
pub_id: cursor
}
}
cursor
}
]),
getNextPageParam: (lastPage) => lastPage.cursor ?? undefined,

View File

@@ -7,7 +7,8 @@ import {
useLibraryContext,
useRspcLibraryContext
} from '@sd/client';
import { getExplorerStore } from '../Explorer/store';
import { useExplorerContext } from '../Explorer/Context';
import { getExplorerStore, useExplorerStore } from '../Explorer/store';
import { UseExplorerSettings } from '../Explorer/useExplorer';
export const IconForCategory: Partial<Record<Category, string>> = {
@@ -86,11 +87,7 @@ export function useItems(
'search.paths',
{
...queryKey[1].arg,
pagination: {
cursor: {
pub_id: cursor
}
}
cursor
}
]),
getNextPageParam: (lastPage) => lastPage.cursor ?? undefined,
@@ -119,11 +116,7 @@ export function useItems(
'search.objects',
{
...queryKey[1].arg,
pagination: {
cursor: {
pub_id: cursor
}
}
cursor
}
]),
getNextPageParam: (lastPage) => lastPage.cursor ?? undefined

View File

@@ -142,9 +142,7 @@ export type FilePath = { id: number; pub_id: number[]; is_dir: boolean | null; c
export type FilePathFilterArgs = { locationId?: number | null; search?: string | null; extension?: string | null; createdAt?: OptionalRange<string>; path?: string | null; object?: ObjectFilterArgs | null }
export type FilePathPagination = { cursor: { pub_id: number[] } } | { offset: number }
export type FilePathSearchArgs = { take?: number | null; order?: FilePathSearchOrdering | null; pagination?: FilePathPagination | null; filter?: FilePathFilterArgs; groupDirectories?: boolean }
export type FilePathSearchArgs = { take?: number | null; order?: FilePathSearchOrdering | null; cursor?: number[] | null; filter?: FilePathFilterArgs; groupDirectories?: boolean }
export type FilePathSearchOrdering = { field: "name"; value: SortOrder } | { field: "sizeInBytes"; value: SortOrder } | { field: "dateCreated"; value: SortOrder } | { field: "dateModified"; value: SortOrder } | { field: "dateIndexed"; value: SortOrder } | { field: "object"; value: ObjectSearchOrdering }
@@ -264,9 +262,7 @@ export type ObjectFilterArgs = { favorite?: boolean | null; hidden?: ObjectHidde
export type ObjectHiddenFilter = "exclude" | "include"
export type ObjectPagination = { cursor: { pub_id: number[] } } | { offset: number }
export type ObjectSearchArgs = { take?: number | null; order?: ObjectSearchOrdering | null; pagination?: ObjectPagination | null; filter?: ObjectFilterArgs }
export type ObjectSearchArgs = { take?: number | null; order?: ObjectSearchOrdering | null; cursor?: number[] | null; filter?: ObjectFilterArgs }
export type ObjectSearchOrdering = { field: "dateAccessed"; value: SortOrder } | { field: "kind"; value: SortOrder }