mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-04 05:15:09 -04:00
Fix categories queries (#971)
* more stringent hidden filter check * add missing migration case * don't do sync stuff when sync disabled * remove old stuff
This commit is contained in:
@@ -16,7 +16,7 @@ use crate::{
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use chrono::{DateTime, FixedOffset, Utc};
|
||||
use prisma_client_rust::operator::or;
|
||||
use prisma_client_rust::{operator, or};
|
||||
use rspc::{alpha::AlphaRouter, ErrorCode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
@@ -110,8 +110,8 @@ impl<T> MaybeNot<T> {
|
||||
struct FilePathFilterArgs {
|
||||
#[specta(optional)]
|
||||
location_id: Option<location::id::Type>,
|
||||
#[serde(default)]
|
||||
search: String,
|
||||
#[specta(optional)]
|
||||
search: Option<String>,
|
||||
#[specta(optional)]
|
||||
extension: Option<String>,
|
||||
#[serde(default)]
|
||||
@@ -169,7 +169,10 @@ enum ObjectHiddenFilter {
|
||||
impl ObjectHiddenFilter {
|
||||
fn to_param(&self) -> Option<object::WhereParam> {
|
||||
match self {
|
||||
ObjectHiddenFilter::Exclude => Some(object::hidden::not(Some(true))),
|
||||
ObjectHiddenFilter::Exclude => Some(or![
|
||||
object::hidden::equals(None),
|
||||
object::hidden::not(Some(true))
|
||||
]),
|
||||
ObjectHiddenFilter::Include => None,
|
||||
}
|
||||
}
|
||||
@@ -204,7 +207,7 @@ impl ObjectFilterArgs {
|
||||
(!self.kind.is_empty()).then(|| kind::in_vec(self.kind.into_iter().collect())),
|
||||
(!self.tags.is_empty()).then(|| {
|
||||
let tags = self.tags.into_iter().map(tag::id::equals).collect();
|
||||
let tags_on_object = tag_on_object::tag::is(vec![or(tags)]);
|
||||
let tags_on_object = tag_on_object::tag::is(vec![operator::or(tags)]);
|
||||
|
||||
tags::some(vec![tags_on_object])
|
||||
}),
|
||||
@@ -274,6 +277,7 @@ pub fn mount() -> AlphaRouter<Ctx> {
|
||||
let params = chain_optional_iter(
|
||||
filter
|
||||
.search
|
||||
.unwrap_or_default()
|
||||
.split(' ')
|
||||
.map(str::to_string)
|
||||
.map(name::contains),
|
||||
|
||||
@@ -134,6 +134,7 @@ impl Migrate for LibraryConfig {
|
||||
|
||||
config.insert("node_id".into(), Value::String(node_id.to_string()));
|
||||
}
|
||||
4 => {} // -_-
|
||||
v => unreachable!("Missing migration for library version {}", v),
|
||||
}
|
||||
|
||||
|
||||
@@ -95,34 +95,41 @@ impl SyncManager {
|
||||
op: CRDTOperation,
|
||||
query: Q,
|
||||
) -> prisma_client_rust::Result<<Q as prisma_client_rust::BatchItemParent>::ReturnValue> {
|
||||
let ret = match &op.typ {
|
||||
CRDTOperationType::Shared(shared_op) => {
|
||||
let kind = match &shared_op.data {
|
||||
SharedOperationData::Create(_) => "c",
|
||||
SharedOperationData::Update { .. } => "u",
|
||||
SharedOperationData::Delete => "d",
|
||||
};
|
||||
#[cfg(feature = "sync-messages")]
|
||||
let ret = {
|
||||
let ret = match &op.typ {
|
||||
CRDTOperationType::Shared(shared_op) => {
|
||||
let kind = match &shared_op.data {
|
||||
SharedOperationData::Create(_) => "c",
|
||||
SharedOperationData::Update { .. } => "u",
|
||||
SharedOperationData::Delete => "d",
|
||||
};
|
||||
|
||||
tx._batch((
|
||||
tx.shared_operation().create(
|
||||
op.id.as_bytes().to_vec(),
|
||||
op.timestamp.0 as i64,
|
||||
shared_op.model.to_string(),
|
||||
to_vec(&shared_op.record_id).unwrap(),
|
||||
kind.to_string(),
|
||||
to_vec(&shared_op.data).unwrap(),
|
||||
node::pub_id::equals(op.node.as_bytes().to_vec()),
|
||||
vec![],
|
||||
),
|
||||
query,
|
||||
))
|
||||
.await?
|
||||
.1
|
||||
}
|
||||
_ => todo!(),
|
||||
tx._batch((
|
||||
tx.shared_operation().create(
|
||||
op.id.as_bytes().to_vec(),
|
||||
op.timestamp.0 as i64,
|
||||
shared_op.model.to_string(),
|
||||
to_vec(&shared_op.record_id).unwrap(),
|
||||
kind.to_string(),
|
||||
to_vec(&shared_op.data).unwrap(),
|
||||
node::pub_id::equals(op.node.as_bytes().to_vec()),
|
||||
vec![],
|
||||
),
|
||||
query,
|
||||
))
|
||||
.await?
|
||||
.1
|
||||
}
|
||||
_ => todo!(),
|
||||
};
|
||||
|
||||
self.tx.send(SyncMessage::Created(op)).ok();
|
||||
|
||||
ret
|
||||
};
|
||||
|
||||
self.tx.send(SyncMessage::Created(op)).ok();
|
||||
#[cfg(not(feature = "sync-messages"))]
|
||||
let ret = tx._batch(vec![query]).await?.remove(0);
|
||||
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ export type FileEraserJobInit = { location_id: number; file_path_ids: number[];
|
||||
|
||||
export type FilePath = { id: number; pub_id: number[]; is_dir: boolean | null; cas_id: string | null; integrity_checksum: string | null; location_id: number | null; materialized_path: string | null; name: string | null; extension: string | null; size_in_bytes: string | null; inode: number[] | null; device: number[] | null; object_id: number | null; key_id: number | null; date_created: string | null; date_modified: string | null; date_indexed: string | null }
|
||||
|
||||
export type FilePathFilterArgs = { locationId?: number | null; search?: string; extension?: string | null; createdAt?: OptionalRange<string>; path?: string | null; object?: ObjectFilterArgs | null }
|
||||
export type FilePathFilterArgs = { locationId?: number | null; search?: string | null; extension?: string | null; createdAt?: OptionalRange<string>; path?: string | null; object?: ObjectFilterArgs | null }
|
||||
|
||||
export type FilePathSearchArgs = { take?: number | null; order?: FilePathSearchOrdering | null; cursor?: number[] | null; filter?: FilePathFilterArgs }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user