[ENG-678] Hidden object filtering (#895)

object hidden filter
This commit is contained in:
Brendan Allan
2023-05-31 12:56:36 +02:00
committed by GitHub
parent f2911d1c96
commit 00dba54082
2 changed files with 23 additions and 4 deletions

View File

@@ -155,13 +155,30 @@ impl ObjectSearchOrdering {
}
}
#[derive(Deserialize, Type, Debug, Default)]
#[serde(rename_all = "camelCase")]
enum ObjectHiddenFilter {
#[default]
Exclude,
Include,
}
impl Into<Option<object::WhereParam>> for ObjectHiddenFilter {
fn into(self) -> Option<object::WhereParam> {
match self {
Self::Exclude => Some(object::hidden::not(true)),
Self::Include => None,
}
}
}
#[derive(Deserialize, Type, Debug, Default)]
#[serde(rename_all = "camelCase")]
struct ObjectFilterArgs {
#[specta(optional)]
favorite: Option<bool>,
#[specta(optional)]
hidden: Option<bool>,
#[serde(default)]
hidden: ObjectHiddenFilter,
#[specta(optional)]
date_accessed: Option<MaybeNot<Option<chrono::DateTime<FixedOffset>>>>,
#[serde(default)]
@@ -175,8 +192,8 @@ impl ObjectFilterArgs {
chain_optional_iter(
[],
[
self.hidden.into(),
self.favorite.map(object::favorite::equals),
self.hidden.map(object::hidden::equals),
self.date_accessed
.map(|date| date.into_prisma(object::date_accessed::equals)),
(!self.kind.is_empty())

View File

@@ -243,7 +243,9 @@ export type Nonce = { XChaCha20Poly1305: number[] } | { Aes256Gcm: number[] }
export type Object = { id: number; pub_id: number[]; kind: number; key_id: number | null; hidden: boolean; favorite: boolean; important: boolean; has_thumbnail: boolean; has_thumbstrip: boolean; has_video_preview: boolean; ipfs_id: string | null; note: string | null; date_created: string; date_accessed: string | null }
export type ObjectFilterArgs = { favorite?: boolean | null; hidden?: boolean | null; dateAccessed?: MaybeNot<string | null> | null; kind?: number[]; tags?: number[] }
export type ObjectFilterArgs = { favorite?: boolean | null; hidden?: ObjectHiddenFilter; dateAccessed?: MaybeNot<string | null> | null; kind?: number[]; tags?: number[] }
export type ObjectHiddenFilter = "exclude" | "include"
export type ObjectSearchArgs = { take?: number | null; order?: ObjectSearchOrdering | null; cursor?: number[] | null; filter?: ObjectFilterArgs }