Skip to content

Commit

Permalink
refactor(webserver): rename disk usage fields
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys committed May 2, 2024
1 parent 5536adc commit 0ee8adb
Show file tree
Hide file tree
Showing 71 changed files with 250 additions and 247 deletions.
26 changes: 13 additions & 13 deletions ee/tabby-ui/app/(dashboard)/system/components/cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,20 @@ export const getDiskUsageStats = graphql(/* GraphQL */ `
query GetDiskUsageStats {
diskUsageStats {
events {
filePaths
size
filepath
sizeKb
}
indexedRepositories {
filePaths
size
filepath
sizeKb
}
database {
filePaths
size
filepath
sizeKb
}
models {
filePaths
size
filepath
sizeKb
}
}
}
Expand All @@ -160,7 +160,7 @@ type UsageItem = {
color: string
}

type UsageItemWithSize = UsageItem & { size: number }
type UsageItemWithSize = UsageItem & { sizeKb: number }

const usageList: UsageItem[] = [
{
Expand Down Expand Up @@ -199,11 +199,11 @@ function Usage() {
const diskUsage = data.diskUsageStats[usage.key] as DiskUsage
return {
...usage,
size: diskUsage.size
sizeKb: diskUsage.sizeKb
}
})
.filter(usage => usage) as UsageItemWithSize[]
totalUsage = sum(usageData.map(data => data.size))
totalUsage = sum(usageData.map(data => data.sizeKb))
}

return (
Expand Down Expand Up @@ -236,7 +236,7 @@ function Usage() {
<div>
<p className="mb-1 leading-none">{usage!.label}</p>
<p className="text-card-foreground/70">
{toBytes(usage!.size)}
{toBytes(usage!.sizeKb)}
</p>
</div>
</div>
Expand All @@ -250,5 +250,5 @@ function Usage() {
}

function toBytes(value: number) {
return prettyBytes(value * 1024)
return prettyBytes(value * 1000)
}
5 changes: 3 additions & 2 deletions ee/tabby-webserver/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ type UserEdge {
}

type DiskUsage {
filePaths: [String!]!
size: Float!
filepath: [String!]!
"Size in kilobytes."
sizeKb: Float!
}

type JobRunConnection {
Expand Down
14 changes: 8 additions & 6 deletions ee/tabby-webserver/src/schema/analytic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ pub struct DiskUsageStats {

#[derive(GraphQLObject)]
pub struct DiskUsage {
pub file_paths: Vec<String>,
pub size: f64,
pub filepath: Vec<String>,

/// Size in kilobytes.
pub size_kb: f64,
}

impl DiskUsage {
pub fn combine(self, other: Self) -> Self {
DiskUsage {
size: self.size + other.size,
file_paths: self
.file_paths
size_kb: self.size_kb + other.size_kb,
filepath: self
.filepath
.into_iter()
.chain(other.file_paths)
.chain(other.filepath)
.collect(),
}
}
Expand Down
12 changes: 6 additions & 6 deletions ee/tabby-webserver/src/service/analytic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ async fn recursive_dir_size(path: PathBuf) -> Result<DiskUsage, anyhow::Error> {
};

Ok(DiskUsage {
file_paths: vec![path_str],
size: size as f64 / 1024.0,
filepath: vec![path_str],
size_kb: size as f64 / 1000.0,
})
}

Expand Down Expand Up @@ -350,9 +350,9 @@ mod tests {

let disk_usage = service.disk_usage_stats().await.unwrap();

assert_eq!(disk_usage.events.size, 0.0);
assert_eq!(disk_usage.indexed_repositories.size, 0.0);
assert_eq!(disk_usage.database.size, 0.0);
assert_eq!(disk_usage.models.size, 1.0);
assert_eq!(disk_usage.events.size_kb, 0.0);
assert_eq!(disk_usage.indexed_repositories.size_kb, 0.0);
assert_eq!(disk_usage.database.size_kb, 0.0);
assert_eq!(disk_usage.models.size_kb, 1.0);
}
}
2 changes: 1 addition & 1 deletion ee/tabby-webserver/ui/404.html

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ee/tabby-webserver/ui/activities.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions ee/tabby-webserver/ui/activities.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
1:HL["/_next/static/media/86fdec36ddd9097e-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
2:HL["/_next/static/media/c9a5bc6a7c948fb0-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
3:HL["/_next/static/css/1a49e85d7522d4c1.css","style"]
0:["0MM6bMvwlgrOLbOgE71q4",[[["",{"children":["(dashboard)",{"children":["activities",{"children":["__PAGE__",{}]}]}]},"$undefined","$undefined",true],"$L4",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/1a49e85d7522d4c1.css","precedence":"next"}]],"$L5"]]]]
6:I{"id":78495,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1424:static/chunks/1424-454dcec055103473.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2453:static/chunks/2453-cbd8ebe27ee2c85e.js","7753:static/chunks/7753-2e4124eaa73e46d7.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","3185:static/chunks/app/layout-363768dca7019271.js"],"name":"Providers","async":false}
0:["dfEvWFaN8ltpT4ksdzs6u",[[["",{"children":["(dashboard)",{"children":["activities",{"children":["__PAGE__",{}]}]}]},"$undefined","$undefined",true],"$L4",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/1a49e85d7522d4c1.css","precedence":"next"}]],"$L5"]]]]
6:I{"id":78495,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1424:static/chunks/1424-454dcec055103473.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2453:static/chunks/2453-cbd8ebe27ee2c85e.js","7753:static/chunks/7753-591873877c4e13de.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","3185:static/chunks/app/layout-363768dca7019271.js"],"name":"Providers","async":false}
7:I{"id":81443,"chunks":["2272:static/chunks/webpack-10e7c3c555f15277.js","2971:static/chunks/fd9d1056-1908058eb8be54df.js","7864:static/chunks/7864-52c05c790493c7b0.js"],"name":"","async":false}
8:I{"id":18639,"chunks":["2272:static/chunks/webpack-10e7c3c555f15277.js","2971:static/chunks/fd9d1056-1908058eb8be54df.js","7864:static/chunks/7864-52c05c790493c7b0.js"],"name":"","async":false}
9:I{"id":97848,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1396:static/chunks/1396-56aec5aee2a8284a.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2553:static/chunks/2553-4765166cfbb35a22.js","713:static/chunks/713-a1efcecf1ebb1f78.js","3815:static/chunks/3815-4e0d7091d4b5dd6e.js","2256:static/chunks/2256-f8542e8ac3c9802b.js","3291:static/chunks/3291-a169ec537558da01.js","7081:static/chunks/7081-527e530c6732c0ed.js","7468:static/chunks/7468-ab3acd4f167ed911.js","6997:static/chunks/6997-14ce3685a011c03e.js","7753:static/chunks/7753-2e4124eaa73e46d7.js","4168:static/chunks/4168-c7d429dc2ca707fc.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","5642:static/chunks/app/(dashboard)/layout-65c7fb5ed708a6d7.js"],"name":"","async":false}
a:I{"id":18851,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1396:static/chunks/1396-56aec5aee2a8284a.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2553:static/chunks/2553-4765166cfbb35a22.js","713:static/chunks/713-a1efcecf1ebb1f78.js","3815:static/chunks/3815-4e0d7091d4b5dd6e.js","2256:static/chunks/2256-f8542e8ac3c9802b.js","3291:static/chunks/3291-a169ec537558da01.js","7081:static/chunks/7081-527e530c6732c0ed.js","7468:static/chunks/7468-ab3acd4f167ed911.js","6997:static/chunks/6997-14ce3685a011c03e.js","7753:static/chunks/7753-2e4124eaa73e46d7.js","4168:static/chunks/4168-c7d429dc2ca707fc.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","5642:static/chunks/app/(dashboard)/layout-65c7fb5ed708a6d7.js"],"name":"ScrollArea","async":false}
b:I{"id":13332,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1396:static/chunks/1396-56aec5aee2a8284a.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2553:static/chunks/2553-4765166cfbb35a22.js","713:static/chunks/713-a1efcecf1ebb1f78.js","3815:static/chunks/3815-4e0d7091d4b5dd6e.js","2256:static/chunks/2256-f8542e8ac3c9802b.js","3291:static/chunks/3291-a169ec537558da01.js","7081:static/chunks/7081-527e530c6732c0ed.js","7468:static/chunks/7468-ab3acd4f167ed911.js","6997:static/chunks/6997-14ce3685a011c03e.js","7753:static/chunks/7753-2e4124eaa73e46d7.js","4168:static/chunks/4168-c7d429dc2ca707fc.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","5642:static/chunks/app/(dashboard)/layout-65c7fb5ed708a6d7.js"],"name":"Header","async":false}
d:I{"id":72472,"chunks":["6990:static/chunks/13b76428-f0fe9fe157a3353a.js","7326:static/chunks/2626716e-b496a3b36b79551a.js","768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1424:static/chunks/1424-454dcec055103473.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2553:static/chunks/2553-4765166cfbb35a22.js","2453:static/chunks/2453-cbd8ebe27ee2c85e.js","6155:static/chunks/6155-3a4dd48282a7c8df.js","9079:static/chunks/9079-d9806d15e6b247ec.js","2704:static/chunks/2704-1b563be0adea7455.js","7753:static/chunks/7753-2e4124eaa73e46d7.js","4168:static/chunks/4168-c7d429dc2ca707fc.js","7957:static/chunks/7957-1382b7c653280fe0.js","4986:static/chunks/app/(dashboard)/activities/page-38d598018c0a89a5.js"],"name":"","async":false}
e:I{"id":42761,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1424:static/chunks/1424-454dcec055103473.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2453:static/chunks/2453-cbd8ebe27ee2c85e.js","7753:static/chunks/7753-2e4124eaa73e46d7.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","3185:static/chunks/app/layout-363768dca7019271.js"],"name":"Toaster","async":false}
9:I{"id":97848,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1396:static/chunks/1396-56aec5aee2a8284a.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2553:static/chunks/2553-4765166cfbb35a22.js","713:static/chunks/713-a1efcecf1ebb1f78.js","3815:static/chunks/3815-4e0d7091d4b5dd6e.js","2256:static/chunks/2256-f8542e8ac3c9802b.js","3291:static/chunks/3291-a169ec537558da01.js","7081:static/chunks/7081-527e530c6732c0ed.js","7468:static/chunks/7468-ab3acd4f167ed911.js","6997:static/chunks/6997-14ce3685a011c03e.js","7753:static/chunks/7753-591873877c4e13de.js","4168:static/chunks/4168-c7d429dc2ca707fc.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","5642:static/chunks/app/(dashboard)/layout-65c7fb5ed708a6d7.js"],"name":"","async":false}
a:I{"id":18851,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1396:static/chunks/1396-56aec5aee2a8284a.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2553:static/chunks/2553-4765166cfbb35a22.js","713:static/chunks/713-a1efcecf1ebb1f78.js","3815:static/chunks/3815-4e0d7091d4b5dd6e.js","2256:static/chunks/2256-f8542e8ac3c9802b.js","3291:static/chunks/3291-a169ec537558da01.js","7081:static/chunks/7081-527e530c6732c0ed.js","7468:static/chunks/7468-ab3acd4f167ed911.js","6997:static/chunks/6997-14ce3685a011c03e.js","7753:static/chunks/7753-591873877c4e13de.js","4168:static/chunks/4168-c7d429dc2ca707fc.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","5642:static/chunks/app/(dashboard)/layout-65c7fb5ed708a6d7.js"],"name":"ScrollArea","async":false}
b:I{"id":13332,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1396:static/chunks/1396-56aec5aee2a8284a.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2553:static/chunks/2553-4765166cfbb35a22.js","713:static/chunks/713-a1efcecf1ebb1f78.js","3815:static/chunks/3815-4e0d7091d4b5dd6e.js","2256:static/chunks/2256-f8542e8ac3c9802b.js","3291:static/chunks/3291-a169ec537558da01.js","7081:static/chunks/7081-527e530c6732c0ed.js","7468:static/chunks/7468-ab3acd4f167ed911.js","6997:static/chunks/6997-14ce3685a011c03e.js","7753:static/chunks/7753-591873877c4e13de.js","4168:static/chunks/4168-c7d429dc2ca707fc.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","5642:static/chunks/app/(dashboard)/layout-65c7fb5ed708a6d7.js"],"name":"Header","async":false}
d:I{"id":72472,"chunks":["6990:static/chunks/13b76428-f0fe9fe157a3353a.js","7326:static/chunks/2626716e-b496a3b36b79551a.js","768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1424:static/chunks/1424-454dcec055103473.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2553:static/chunks/2553-4765166cfbb35a22.js","2453:static/chunks/2453-cbd8ebe27ee2c85e.js","6155:static/chunks/6155-3a4dd48282a7c8df.js","9079:static/chunks/9079-d9806d15e6b247ec.js","2704:static/chunks/2704-1b563be0adea7455.js","7753:static/chunks/7753-591873877c4e13de.js","4168:static/chunks/4168-c7d429dc2ca707fc.js","7957:static/chunks/7957-1382b7c653280fe0.js","4986:static/chunks/app/(dashboard)/activities/page-38d598018c0a89a5.js"],"name":"","async":false}
e:I{"id":42761,"chunks":["768:static/chunks/768-5f89fb02d50a441c.js","9109:static/chunks/9109-08bf42cc9883c73f.js","584:static/chunks/584-4a34f53d05daf959.js","3072:static/chunks/3072-c6632acab1bab4ae.js","1424:static/chunks/1424-454dcec055103473.js","2699:static/chunks/2699-d97820a36669949a.js","7070:static/chunks/7070-b53097eca5027517.js","2453:static/chunks/2453-cbd8ebe27ee2c85e.js","7753:static/chunks/7753-591873877c4e13de.js","2445:static/chunks/2445-5f1479ca5d9d10e0.js","3185:static/chunks/app/layout-363768dca7019271.js"],"name":"Toaster","async":false}
5:[["$","meta","0",{"charSet":"utf-8"}],["$","title","1",{"children":"Tabby - Activities"}],["$","meta","2",{"name":"description","content":"Tabby, an opensource, self-hosted AI coding assistant."}],["$","meta","3",{"name":"theme-color","media":"(prefers-color-scheme: light)","content":"white"}],["$","meta","4",{"name":"theme-color","media":"(prefers-color-scheme: dark)","content":"black"}],["$","meta","5",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","6",{"name":"next-size-adjust"}]]
4:[null,["$","html",null,{"lang":"en","suppressHydrationWarning":true,"children":[["$","head",null,{}],["$","body",null,{"className":"font-sans antialiased __variable_aaf875 __variable_2c91d1","children":["$","$L6",null,{"attribute":"class","defaultTheme":"system","enableSystem":true,"children":[["$","div",null,{"className":"flex min-h-screen flex-col","children":["$","$L7",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$L8",null,{}],"templateStyles":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"childProp":{"current":[null,["$","main",null,{"className":"flex flex-1","children":[["$","$L9",null,{}],["$","$La",null,{"className":"flex h-[100vh] flex-1 flex-col","children":[["$","$Lb",null,{}],["$","div",null,{"className":"flex-1 p-4 lg:p-10","children":["$","$L7",null,{"parallelRouterKey":"children","segmentPath":["children","(dashboard)","children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$L8",null,{}],"templateStyles":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"childProp":{"current":["$","$L7",null,{"parallelRouterKey":"children","segmentPath":["children","(dashboard)","children","activities","children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$L8",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$Lc",["$","$Ld",null,{}],null],"segment":"__PAGE__"},"styles":[]}],"segment":"activities"},"styles":[]}]}]]}]]}],null],"segment":"(dashboard)"},"styles":[]}]}],["$","$Le",null,{"richColors":true,"closeButton":true}],null]}]}]]}],null]
c:null
Loading

0 comments on commit 0ee8adb

Please sign in to comment.