Skip to content

Commit c38f5f7

Browse files
committed
style: fix formatting and ignore txt files
1 parent 1282991 commit c38f5f7

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ TODO.md
1212
ROADMAP*.md
1313
docs-site/
1414
docs/
15+
*.txt

nora-registry/src/repo_index.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,19 @@ async fn build_docker_index(storage: &Storage) -> Vec<RepoInfo> {
181181

182182
if let Ok(data) = storage.get(key).await {
183183
if let Ok(m) = serde_json::from_slice::<serde_json::Value>(&data) {
184-
let cfg = m.get("config").and_then(|c| c.get("size")).and_then(|s| s.as_u64()).unwrap_or(0);
185-
let layers: u64 = m.get("layers").and_then(|l| l.as_array())
186-
.map(|arr| arr.iter().filter_map(|l| l.get("size").and_then(|s| s.as_u64())).sum())
184+
let cfg = m
185+
.get("config")
186+
.and_then(|c| c.get("size"))
187+
.and_then(|s| s.as_u64())
188+
.unwrap_or(0);
189+
let layers: u64 = m
190+
.get("layers")
191+
.and_then(|l| l.as_array())
192+
.map(|arr| {
193+
arr.iter()
194+
.filter_map(|l| l.get("size").and_then(|s| s.as_u64()))
195+
.sum()
196+
})
187197
.unwrap_or(0);
188198
entry.1 += cfg + layers;
189199
}

nora-registry/src/ui/api.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ pub async fn api_stats(State(state): State<Arc<AppState>>) -> Json<RegistryStats
116116
let _ = state.repo_index.get("pypi", &state.storage).await;
117117

118118
let (docker, maven, npm, cargo, pypi) = state.repo_index.counts();
119-
Json(RegistryStats { docker, maven, npm, cargo, pypi })
119+
Json(RegistryStats {
120+
docker,
121+
maven,
122+
npm,
123+
cargo,
124+
pypi,
125+
})
120126
}
121127

122128
pub async fn api_dashboard(State(state): State<Arc<AppState>>) -> Json<DashboardResponse> {
@@ -135,8 +141,11 @@ pub async fn api_dashboard(State(state): State<Arc<AppState>>) -> Json<Dashboard
135141
let pypi_size: u64 = pypi_repos.iter().map(|r| r.size).sum();
136142
let total_storage = docker_size + maven_size + npm_size + cargo_size + pypi_size;
137143

138-
let total_artifacts = docker_repos.len() + maven_repos.len() + npm_repos.len()
139-
+ cargo_repos.len() + pypi_repos.len();
144+
let total_artifacts = docker_repos.len()
145+
+ maven_repos.len()
146+
+ npm_repos.len()
147+
+ cargo_repos.len()
148+
+ pypi_repos.len();
140149

141150
let global_stats = GlobalStats {
142151
downloads: state.metrics.downloads.load(Ordering::Relaxed),

nora-registry/src/ui/templates.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// SPDX-License-Identifier: MIT
33

44
use super::api::{DashboardResponse, DockerDetail, MavenDetail, PackageDetail};
5-
use crate::repo_index::RepoInfo;
65
use super::components::*;
76
use super::i18n::{get_translations, Lang};
7+
use crate::repo_index::RepoInfo;
88

99
/// Renders the main dashboard page with dark theme
1010
pub fn render_dashboard(data: &DashboardResponse, lang: Lang) -> String {
@@ -304,7 +304,8 @@ pub fn render_registry_list_paginated(
304304
r##"<tr><td colspan="4" class="px-6 py-12 text-center text-slate-500">
305305
<div class="text-4xl mb-2">📭</div>
306306
<div>No more items on this page</div>
307-
</td></tr>"##.to_string()
307+
</td></tr>"##
308+
.to_string()
308309
} else {
309310
repos
310311
.iter()
@@ -341,7 +342,11 @@ pub fn render_registry_list_paginated(
341342

342343
// Pagination
343344
let total_pages = (total + limit - 1) / limit;
344-
let start_item = if total == 0 { 0 } else { (page - 1) * limit + 1 };
345+
let start_item = if total == 0 {
346+
0
347+
} else {
348+
(page - 1) * limit + 1
349+
};
345350
let end_item = (start_item + repos.len()).saturating_sub(1);
346351

347352
let pagination = if total_pages > 1 {

0 commit comments

Comments
 (0)