Skip to content

Commit 4e14211

Browse files
Fmt
1 parent 273b846 commit 4e14211

File tree

3 files changed

+17
-28
lines changed

3 files changed

+17
-28
lines changed

src/tui/handlers/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ pub fn app_event_handler(app: &mut App, event: AppEvent) -> Result<()> {
241241
if let Some(current_page) = app.state.sql_tab.current_page() {
242242
let next_page = current_page + 1;
243243
if app.state.sql_tab.needs_more_batches_for_page(next_page) {
244-
info!("Still need more batches for page {}, fetching next batch", next_page);
244+
info!(
245+
"Still need more batches for page {}, fetching next batch",
246+
next_page
247+
);
245248
let execution = Arc::clone(&app.execution);
246249
let sql = query.clone();
247250
let _event_tx = app.event_tx();

src/tui/state/tabs/sql.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,17 @@ impl SQLTabState<'_> {
243243
}
244244

245245
pub fn current_page_results(&self) -> Option<RecordBatch> {
246-
use std::sync::Arc;
247246
use datafusion::arrow::datatypes::Schema;
247+
use std::sync::Arc;
248248

249249
match (self.current_page, self.result_batches.as_ref()) {
250-
(Some(page), Some(batches)) => {
251-
match extract_page(batches, page, PAGE_SIZE) {
252-
Ok(batch) => Some(batch),
253-
Err(err) => {
254-
log::error!("Error getting page {}: {}", page, err);
255-
None
256-
}
250+
(Some(page), Some(batches)) => match extract_page(batches, page, PAGE_SIZE) {
251+
Ok(batch) => Some(batch),
252+
Err(err) => {
253+
log::error!("Error getting page {}: {}", page, err);
254+
None
257255
}
258-
}
256+
},
259257
_ => Some(RecordBatch::new_empty(Arc::new(Schema::empty()))),
260258
}
261259
}

tests/tui_cases/sql_pagination.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ fn create_values_query_offset(num: usize, offset: usize) -> String {
5858
async fn single_page() {
5959
let mut test_app = TestApp::new().await;
6060

61-
test_app
62-
.handle_app_event(AppEvent::NewExecution)
63-
.unwrap();
61+
test_app.handle_app_event(AppEvent::NewExecution).unwrap();
6462
let res1 = create_execution_results("SELECT 1").await;
6563
let event1 = AppEvent::ExecutionResultsNextBatch(res1);
6664
test_app.handle_app_event(event1).unwrap();
@@ -97,9 +95,7 @@ async fn multiple_pages_forward_and_back() {
9795
let res1 = create_execution_results(&query).await;
9896
let event1 = AppEvent::ExecutionResultsNextBatch(res1);
9997

100-
test_app
101-
.handle_app_event(AppEvent::NewExecution)
102-
.unwrap();
98+
test_app.handle_app_event(AppEvent::NewExecution).unwrap();
10399
test_app.handle_app_event(event1).unwrap();
104100

105101
{
@@ -165,9 +161,7 @@ async fn multiple_pages_forward_and_back_and_forward() {
165161
let res1 = create_execution_results(&query).await;
166162
let event1 = AppEvent::ExecutionResultsNextBatch(res1);
167163

168-
test_app
169-
.handle_app_event(AppEvent::NewExecution)
170-
.unwrap();
164+
test_app.handle_app_event(AppEvent::NewExecution).unwrap();
171165
test_app.handle_app_event(event1).unwrap();
172166

173167
{
@@ -219,9 +213,7 @@ async fn multiple_pages_forward_and_back_and_forward() {
219213
async fn multiple_batches_lazy_loading() {
220214
let mut test_app = TestApp::new().await;
221215

222-
test_app
223-
.handle_app_event(AppEvent::NewExecution)
224-
.unwrap();
216+
test_app.handle_app_event(AppEvent::NewExecution).unwrap();
225217

226218
// Send only first batch initially (lazy loading)
227219
let batch1 = create_execution_results(&create_values_query(60)).await;
@@ -277,9 +269,7 @@ async fn multiple_batches_lazy_loading() {
277269
async fn multiple_small_batches_auto_load() {
278270
let mut test_app = TestApp::new().await;
279271

280-
test_app
281-
.handle_app_event(AppEvent::NewExecution)
282-
.unwrap();
272+
test_app.handle_app_event(AppEvent::NewExecution).unwrap();
283273

284274
// Send first batch: 100 rows (fills page 0)
285275
let batch1 = create_execution_results(&create_values_query(100)).await;
@@ -359,9 +349,7 @@ async fn multiple_small_batches_auto_load() {
359349
async fn exact_batches_for_page() {
360350
let mut test_app = TestApp::new().await;
361351

362-
test_app
363-
.handle_app_event(AppEvent::NewExecution)
364-
.unwrap();
352+
test_app.handle_app_event(AppEvent::NewExecution).unwrap();
365353

366354
// Send first batch: 50 rows
367355
let batch1 = create_execution_results(&create_values_query(50)).await;

0 commit comments

Comments
 (0)