picker in forms page have more results easily now
This commit is contained in:
2
client
2
client
Submodule client updated: 4d45b25c75...8fc2b22baa
@@ -24,6 +24,7 @@ message SearchRequest {
|
|||||||
string free_query = 3;
|
string free_query = 3;
|
||||||
repeated ColumnConstraint must = 4;
|
repeated ColumnConstraint must = 4;
|
||||||
optional uint32 limit = 5;
|
optional uint32 limit = 5;
|
||||||
|
optional uint32 offset = 6;
|
||||||
}
|
}
|
||||||
message SearchResponse {
|
message SearchResponse {
|
||||||
message Hit {
|
message Hit {
|
||||||
|
|||||||
Binary file not shown.
@@ -20,6 +20,8 @@ pub struct SearchRequest {
|
|||||||
pub must: ::prost::alloc::vec::Vec<ColumnConstraint>,
|
pub must: ::prost::alloc::vec::Vec<ColumnConstraint>,
|
||||||
#[prost(uint32, optional, tag = "5")]
|
#[prost(uint32, optional, tag = "5")]
|
||||||
pub limit: ::core::option::Option<u32>,
|
pub limit: ::core::option::Option<u32>,
|
||||||
|
#[prost(uint32, optional, tag = "6")]
|
||||||
|
pub offset: ::core::option::Option<u32>,
|
||||||
}
|
}
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct SearchResponse {
|
pub struct SearchResponse {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use tonic::{Request, Response, Status};
|
|||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
const INDEX_ROOT: &str = "./tantivy_indexes";
|
const INDEX_ROOT: &str = "./tantivy_indexes";
|
||||||
const DEFAULT_RESULT_LIMIT: usize = 25;
|
const DEFAULT_RESULT_LIMIT: usize = 60;
|
||||||
const HARD_RESULT_LIMIT: usize = 200;
|
const HARD_RESULT_LIMIT: usize = 200;
|
||||||
const DEFAULT_LIST_LIMIT: usize = 5;
|
const DEFAULT_LIST_LIMIT: usize = 5;
|
||||||
|
|
||||||
@@ -71,6 +71,7 @@ impl SearcherService {
|
|||||||
&normalized.profile_name,
|
&normalized.profile_name,
|
||||||
table_name,
|
table_name,
|
||||||
normalized.limit.unwrap_or(DEFAULT_LIST_LIMIT),
|
normalized.limit.unwrap_or(DEFAULT_LIST_LIMIT),
|
||||||
|
normalized.offset,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(Response::new(SearchResponse { hits }));
|
return Ok(Response::new(SearchResponse { hits }));
|
||||||
@@ -163,6 +164,7 @@ struct NormalizedSearchRequest {
|
|||||||
free_query: String,
|
free_query: String,
|
||||||
must: Vec<NormalizedColumnConstraint>,
|
must: Vec<NormalizedColumnConstraint>,
|
||||||
limit: Option<usize>,
|
limit: Option<usize>,
|
||||||
|
offset: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -310,6 +312,7 @@ fn normalize_request(req: SearchRequest) -> Result<NormalizedSearchRequest, Stat
|
|||||||
let limit = req
|
let limit = req
|
||||||
.limit
|
.limit
|
||||||
.map(|value| (value as usize).min(HARD_RESULT_LIMIT));
|
.map(|value| (value as usize).min(HARD_RESULT_LIMIT));
|
||||||
|
let offset = req.offset.unwrap_or_default() as usize;
|
||||||
|
|
||||||
Ok(NormalizedSearchRequest {
|
Ok(NormalizedSearchRequest {
|
||||||
profile_name: profile_name.to_string(),
|
profile_name: profile_name.to_string(),
|
||||||
@@ -317,6 +320,7 @@ fn normalize_request(req: SearchRequest) -> Result<NormalizedSearchRequest, Stat
|
|||||||
free_query,
|
free_query,
|
||||||
must,
|
must,
|
||||||
limit,
|
limit,
|
||||||
|
offset,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,15 +481,17 @@ async fn fetch_latest_rows(
|
|||||||
profile_name: &str,
|
profile_name: &str,
|
||||||
table_name: &str,
|
table_name: &str,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
offset: usize,
|
||||||
) -> Result<Vec<Hit>, Status> {
|
) -> Result<Vec<Hit>, Status> {
|
||||||
let physical_to_display = table_physical_to_display_map(pool, profile_name, table_name).await?;
|
let physical_to_display = table_physical_to_display_map(pool, profile_name, table_name).await?;
|
||||||
let sql = format!(
|
let sql = format!(
|
||||||
"SELECT id, to_jsonb(t) AS data FROM {} t WHERE deleted = FALSE ORDER BY id DESC LIMIT $1",
|
"SELECT id, to_jsonb(t) AS data FROM {} t WHERE deleted = FALSE ORDER BY id DESC LIMIT $1 OFFSET $2",
|
||||||
qualify_profile_table(profile_name, table_name)
|
qualify_profile_table(profile_name, table_name)
|
||||||
);
|
);
|
||||||
|
|
||||||
let rows = sqlx::query(AssertSqlSafe(sql))
|
let rows = sqlx::query(AssertSqlSafe(sql))
|
||||||
.bind(limit as i64)
|
.bind(limit as i64)
|
||||||
|
.bind(offset as i64)
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| Status::internal(format!("DB query for default results failed: {}", e)))?;
|
.map_err(|e| Status::internal(format!("DB query for default results failed: {}", e)))?;
|
||||||
|
|||||||
2
server
2
server
Submodule server updated: e2909537f5...da3401c26b
Reference in New Issue
Block a user