Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/conviso/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.5
0.3.6
29 changes: 20 additions & 9 deletions src/conviso/commands/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,27 +206,38 @@ def _fetch_page(page_num: int):
typer.echo("⚠️ No projects found.")
raise typer.Exit()

if fetch_all:
disp_page, disp_total_pages = 1, 1
total = len(rows)
start, end = (1, total) if total > 0 else (0, 0)
else:
disp_page = page
disp_total_pages = total_pages or '?'
total = total_count or len(rows)
effective_limit = max(limit, 1)
start = (page - 1) * effective_limit + 1 if total > 0 else 0
end = min(page * effective_limit, total)

export_data(
rows,
schema=schema,
fmt=fmt,
output=output,
title=f"Projects (Company {company_id}) - Page {page}/{total_pages or '?'}",
title=f"Projects (Company {company_id}) - Page {disp_page}/{disp_total_pages}",
)

if fmt != "json":
total = total_count or len(rows)
effective_limit = max(limit, 1)

start = (page - 1) * effective_limit + 1 if total > 0 else 0
end = min(page * effective_limit, total)

total_pages_calc = math.ceil(total / effective_limit)
if not fetch_all and disp_total_pages != '?':
total_pages_calc = disp_total_pages
elif fetch_all:
total_pages_calc = 1
else:
total_pages_calc = math.ceil(total / max(limit, 1))

elapsed = time.perf_counter() - started_at
timed_summary(
f"Showing {start}-{end} of {total} "
f"(page {page}/{total_pages_calc})",
f"(page {disp_page}/{total_pages_calc})",
elapsed,
)

Expand Down
Loading