From 1516f9ae96cabeeb131dd162fa63428d5e646f08 Mon Sep 17 00:00:00 2001
From: rhigman <73792779+rhigman@users.noreply.github.com>
Date: Fri, 27 Aug 2021 16:21:02 +0100
Subject: [PATCH 1/5] Add delete confirmation modal dialogue to Publication
delete button
---
thoth-app/src/component/publication.rs | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/thoth-app/src/component/publication.rs b/thoth-app/src/component/publication.rs
index 7c5649c4..12af937e 100644
--- a/thoth-app/src/component/publication.rs
+++ b/thoth-app/src/component/publication.rs
@@ -18,6 +18,7 @@ use crate::agent::notification_bus::NotificationBus;
use crate::agent::notification_bus::NotificationDispatcher;
use crate::agent::notification_bus::NotificationStatus;
use crate::agent::notification_bus::Request;
+use crate::component::delete_dialogue::ConfirmDeleteComponent;
use crate::component::prices_form::PricesFormComponent;
use crate::component::utils::Loader;
use crate::models::publication::delete_publication_mutation::DeletePublicationRequest;
@@ -32,7 +33,6 @@ use crate::models::publication::publication_query::PublicationRequestBody;
use crate::models::publication::publication_query::Variables;
use crate::route::AdminRoute;
use crate::route::AppRoute;
-use crate::string::DELETE_BUTTON;
pub struct PublicationComponent {
publication: PublicationWithRelations,
@@ -219,9 +219,15 @@ impl Component for PublicationComponent {
-
+
From 370c42a0b7d0e8c8eabcf991570235c297a8bd6c Mon Sep 17 00:00:00 2001
From: rhigman <73792779+rhigman@users.noreply.github.com>
Date: Fri, 27 Aug 2021 16:33:32 +0100
Subject: [PATCH 2/5] Make subjectCount query filter parameter optional (by
supplying empty string as default)
---
thoth-api/src/graphql/model.rs | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/thoth-api/src/graphql/model.rs b/thoth-api/src/graphql/model.rs
index c3a9436d..9bb47ea1 100644
--- a/thoth-api/src/graphql/model.rs
+++ b/thoth-api/src/graphql/model.rs
@@ -815,7 +815,16 @@ impl QueryRoot {
Subject::from_id(&context.db, &subject_id).map_err(|e| e.into())
}
- #[graphql(description = "Get the total number of subjects associated to works")]
+ #[graphql(
+ description = "Get the total number of subjects associated to works",
+ arguments(
+ filter(
+ default = "".to_string(),
+ description = "A query string to search. This argument is a test, do not rely on it. At present it simply searches for case insensitive literals on subject_code",
+ ),
+ subject_type(description = "A specific type to filter by"),
+ )
+ )]
fn subject_count(
context: &Context,
filter: String,
From 988481a5e32ff53392a39b87e81434b6d6bbf678 Mon Sep 17 00:00:00 2001
From: rhigman <73792779+rhigman@users.noreply.github.com>
Date: Fri, 27 Aug 2021 16:46:54 +0100
Subject: [PATCH 3/5] Add lastName to contributor query filter fields
---
thoth-api/src/contributor/crud.rs | 2 ++
thoth-api/src/graphql/model.rs | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/thoth-api/src/contributor/crud.rs b/thoth-api/src/contributor/crud.rs
index 35444747..3737b6e6 100644
--- a/thoth-api/src/contributor/crud.rs
+++ b/thoth-api/src/contributor/crud.rs
@@ -77,6 +77,7 @@ impl Crud for Contributor {
query = query.filter(
full_name
.ilike(format!("%{}%", filter))
+ .or(last_name.ilike(format!("%{}%", filter)))
.or(orcid.ilike(format!("%{}%", filter))),
);
}
@@ -104,6 +105,7 @@ impl Crud for Contributor {
query = query.filter(
full_name
.ilike(format!("%{}%", filter))
+ .or(last_name.ilike(format!("%{}%", filter)))
.or(orcid.ilike(format!("%{}%", filter))),
);
}
diff --git a/thoth-api/src/graphql/model.rs b/thoth-api/src/graphql/model.rs
index 9bb47ea1..a6e3e6d6 100644
--- a/thoth-api/src/graphql/model.rs
+++ b/thoth-api/src/graphql/model.rs
@@ -415,7 +415,7 @@ impl QueryRoot {
offset(default = 0, description = "The number of items to skip"),
filter(
default = "".to_string(),
- description = "A query string to search. This argument is a test, do not rely on it. At present it simply searches for case insensitive literals on full_name and orcid"
+ description = "A query string to search. This argument is a test, do not rely on it. At present it simply searches for case insensitive literals on full_name, last_name and orcid"
),
order(
default = ContributorOrderBy::default(),
@@ -455,7 +455,7 @@ impl QueryRoot {
arguments(
filter(
default = "".to_string(),
- description = "A query string to search. This argument is a test, do not rely on it. At present it simply searches for case insensitive literals on full_name and orcid",
+ description = "A query string to search. This argument is a test, do not rely on it. At present it simply searches for case insensitive literals on full_name, last_name and orcid",
),
)
)]
From d28fef68872b6734c1bcdece7344280164656005 Mon Sep 17 00:00:00 2001
From: rhigman <73792779+rhigman@users.noreply.github.com>
Date: Tue, 31 Aug 2021 13:33:17 +0100
Subject: [PATCH 4/5] Filter on each word of contributor query string
[behaviour is poor: too many results]
---
thoth-api/src/contributor/crud.rs | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/thoth-api/src/contributor/crud.rs b/thoth-api/src/contributor/crud.rs
index 3737b6e6..b1fcbd46 100644
--- a/thoth-api/src/contributor/crud.rs
+++ b/thoth-api/src/contributor/crud.rs
@@ -6,9 +6,7 @@ use crate::graphql::utils::Direction;
use crate::model::{Crud, DbInsert, HistoryEntry};
use crate::schema::{contributor, contributor_history};
use crate::{crud_methods, db_insert};
-use diesel::{
- BoolExpressionMethods, ExpressionMethods, PgTextExpressionMethods, QueryDsl, RunQueryDsl,
-};
+use diesel::{ExpressionMethods, PgTextExpressionMethods, QueryDsl, RunQueryDsl};
use thoth_errors::{ThothError, ThothResult};
use uuid::Uuid;
@@ -74,12 +72,12 @@ impl Crud for Contributor {
},
}
if let Some(filter) = filter {
- query = query.filter(
- full_name
- .ilike(format!("%{}%", filter))
- .or(last_name.ilike(format!("%{}%", filter)))
- .or(orcid.ilike(format!("%{}%", filter))),
- );
+ for substring in filter.split_whitespace() {
+ query = query
+ .or_filter(full_name.ilike(format!("%{}%", substring)))
+ .or_filter(last_name.ilike(format!("%{}%", substring)))
+ .or_filter(orcid.ilike(format!("%{}%", substring)));
+ }
}
match query
.limit(limit.into())
@@ -102,12 +100,12 @@ impl Crud for Contributor {
let connection = db.get().unwrap();
let mut query = contributor.into_boxed();
if let Some(filter) = filter {
- query = query.filter(
- full_name
- .ilike(format!("%{}%", filter))
- .or(last_name.ilike(format!("%{}%", filter)))
- .or(orcid.ilike(format!("%{}%", filter))),
- );
+ for substring in filter.split_whitespace() {
+ query = query
+ .or_filter(full_name.ilike(format!("%{}%", substring)))
+ .or_filter(last_name.ilike(format!("%{}%", substring)))
+ .or_filter(orcid.ilike(format!("%{}%", substring)));
+ }
}
// `SELECT COUNT(*)` in postgres returns a BIGINT, which diesel parses as i64. Juniper does
From 578c560fad28df1971629dc25b23f45f60ab7d71 Mon Sep 17 00:00:00 2001
From: rhigman <73792779+rhigman@users.noreply.github.com>
Date: Tue, 31 Aug 2021 13:33:53 +0100
Subject: [PATCH 5/5] Revert "Filter on each word of contributor query string
[behaviour is poor: too many results]"
This reverts commit d28fef68872b6734c1bcdece7344280164656005.
---
thoth-api/src/contributor/crud.rs | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/thoth-api/src/contributor/crud.rs b/thoth-api/src/contributor/crud.rs
index b1fcbd46..3737b6e6 100644
--- a/thoth-api/src/contributor/crud.rs
+++ b/thoth-api/src/contributor/crud.rs
@@ -6,7 +6,9 @@ use crate::graphql::utils::Direction;
use crate::model::{Crud, DbInsert, HistoryEntry};
use crate::schema::{contributor, contributor_history};
use crate::{crud_methods, db_insert};
-use diesel::{ExpressionMethods, PgTextExpressionMethods, QueryDsl, RunQueryDsl};
+use diesel::{
+ BoolExpressionMethods, ExpressionMethods, PgTextExpressionMethods, QueryDsl, RunQueryDsl,
+};
use thoth_errors::{ThothError, ThothResult};
use uuid::Uuid;
@@ -72,12 +74,12 @@ impl Crud for Contributor {
},
}
if let Some(filter) = filter {
- for substring in filter.split_whitespace() {
- query = query
- .or_filter(full_name.ilike(format!("%{}%", substring)))
- .or_filter(last_name.ilike(format!("%{}%", substring)))
- .or_filter(orcid.ilike(format!("%{}%", substring)));
- }
+ query = query.filter(
+ full_name
+ .ilike(format!("%{}%", filter))
+ .or(last_name.ilike(format!("%{}%", filter)))
+ .or(orcid.ilike(format!("%{}%", filter))),
+ );
}
match query
.limit(limit.into())
@@ -100,12 +102,12 @@ impl Crud for Contributor {
let connection = db.get().unwrap();
let mut query = contributor.into_boxed();
if let Some(filter) = filter {
- for substring in filter.split_whitespace() {
- query = query
- .or_filter(full_name.ilike(format!("%{}%", substring)))
- .or_filter(last_name.ilike(format!("%{}%", substring)))
- .or_filter(orcid.ilike(format!("%{}%", substring)));
- }
+ query = query.filter(
+ full_name
+ .ilike(format!("%{}%", filter))
+ .or(last_name.ilike(format!("%{}%", filter)))
+ .or(orcid.ilike(format!("%{}%", filter))),
+ );
}
// `SELECT COUNT(*)` in postgres returns a BIGINT, which diesel parses as i64. Juniper does