Skip to content

Commit

Permalink
fix: rename file size to database size
Browse files Browse the repository at this point in the history
  • Loading branch information
frectonz committed Jun 24, 2024
1 parent 4e076ec commit 71d3b9d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ mod sqlite {
let metadata = tokio::fs::metadata(&self.path).await?;

let sqlite_version = tokio_rusqlite::version().to_owned();
let file_size = helpers::format_size(metadata.len() as f64);
let db_size = helpers::format_size(metadata.len() as f64);
let modified = Some(metadata.modified()?.into());
let created = metadata.created().ok().map(Into::into);

Expand Down Expand Up @@ -384,7 +384,7 @@ mod sqlite {
Ok(responses::Overview {
file_name,
sqlite_version: Some(sqlite_version),
file_size,
db_size,
created,
modified,
tables,
Expand Down Expand Up @@ -668,7 +668,7 @@ mod libsql {
.ok_or_eyre("could not get page size")?
.get::<u64>(0)?;

let file_size = helpers::format_size((page_count * page_size) as f64);
let db_size = helpers::format_size((page_count * page_size) as f64);
let modified = None;
let created = None;

Expand Down Expand Up @@ -763,7 +763,7 @@ mod libsql {
Ok(responses::Overview {
file_name,
sqlite_version: Some(sqlite_version),
file_size,
db_size,
created,
modified,
tables,
Expand Down Expand Up @@ -1074,12 +1074,12 @@ mod postgres {
.await?
.get(0);

let file_size: i64 = self
let db_size: i64 = self
.client
.query_one("SELECT pg_database_size($1)", &[&file_name])
.await?
.get(0);
let file_size = helpers::format_size(file_size as f64);
let db_size = helpers::format_size(db_size as f64);

let modified = None;
let created = None;
Expand Down Expand Up @@ -1169,7 +1169,7 @@ mod postgres {
Ok(responses::Overview {
file_name,
sqlite_version: None,
file_size,
db_size,
created,
modified,
tables: tables as i32,
Expand Down Expand Up @@ -1424,7 +1424,7 @@ mod mysql {
.map(|name: String| name)
.ok_or_eyre("couldn't get database name")?;

let file_size = r#"
let db_size = r#"
SELECT sum(data_length + index_length) AS size
FROM information_schema.tables
WHERE table_schema = database()
Expand All @@ -1434,7 +1434,7 @@ mod mysql {
.await?
.map(|size: i64| size)
.ok_or_eyre("couldn't get database size")?;
let file_size = helpers::format_size(file_size as f64);
let db_size = helpers::format_size(db_size as f64);

let modified = None;
let created = None;
Expand Down Expand Up @@ -1507,7 +1507,7 @@ mod mysql {
Ok(responses::Overview {
file_name,
sqlite_version: None,
file_size,
db_size,
created,
modified,
tables,
Expand Down Expand Up @@ -1788,7 +1788,7 @@ mod duckdb {

let metadata = tokio::fs::metadata(&self.path).await?;

let file_size = helpers::format_size(metadata.len() as f64);
let db_size = helpers::format_size(metadata.len() as f64);
let modified = Some(metadata.modified()?.into());
let created = metadata.created().ok().map(Into::into);

Expand Down Expand Up @@ -1859,7 +1859,7 @@ mod duckdb {
Ok(responses::Overview {
file_name,
sqlite_version: None,
file_size,
db_size,
created,
modified,
tables,
Expand Down Expand Up @@ -2107,7 +2107,7 @@ mod responses {
#[derive(Serialize)]
pub struct Overview {
pub file_name: String,
pub file_size: String,
pub db_size: String,
pub sqlite_version: Option<String>,
pub created: Option<DateTime<Utc>>,
pub modified: Option<DateTime<Utc>>,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const BASE_URL = import.meta.env.PROD ? "/api" : "http://localhost:3030/api";
const overview = z.object({
file_name: z.string(),
sqlite_version: z.string().nullable(),
file_size: z.string(),
db_size: z.string(),
created: z
.string()
.datetime()
Expand Down
4 changes: 2 additions & 2 deletions ui/src/routes/index.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ function Index() {
<Table>
<TableBody>
<MetadataRow
name="FILE SIZE"
name="DATABASE SIZE"
description="The size of the DB on disk."
value={data.file_size}
value={data.db_size}
/>

{data.sqlite_version && (
Expand Down

0 comments on commit 71d3b9d

Please sign in to comment.