Rafraîchissement par projet, nom obligatoire et fichiers anciens masqués
- Chaque projet choisit sa fréquence de relecture (jamais, 5 s … 1 h) ; le serveur ne relit que les projets dus, le fichier affiché est toujours à jour. Le réglage global et sa page disparaissent (migration de l'ancien intervalle vers chaque projet). - Le nom du projet est obligatoire, proposé d'après le chemin. - Les fichiers non modifiés depuis N jours peuvent être masqués ; ils ne comptent plus dans les non-lus et réapparaissent dès qu'ils changent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
86c8f1bb49
commit
e44e0fd162
9 files changed
+483
-215
No files matched your search
+31
-16
@@ -2,8 +2,8 @@
|
||||
|
||||
use crate::{
|
||||
model::{
|
||||
DEFAULT_INTERVAL, FileSort, FileSummary, LogFormat, LogKind, ProjectSummary, Settings,
|
||||
Summary, parse_log_dirs,
|
||||
FileSort, FileSummary, LogFormat, LogKind, ProjectSummary, Settings, Summary, is_hidden,
|
||||
parse_log_dirs,
|
||||
},
|
||||
scanner::Scanner,
|
||||
};
|
||||
@@ -90,20 +90,12 @@ pub async fn set_setting(pool: &SqlitePool, key: &str, value: &str) -> sqlx::Res
|
||||
}
|
||||
|
||||
pub async fn load_settings(pool: &SqlitePool) -> sqlx::Result<Settings> {
|
||||
let refresh_interval_seconds = setting(pool, "refresh_interval_seconds")
|
||||
.await?
|
||||
.and_then(|v| v.parse().ok())
|
||||
.unwrap_or(DEFAULT_INTERVAL);
|
||||
let file_sort = setting(pool, "file_sort")
|
||||
.await?
|
||||
.and_then(|v| FileSort::parse(&v))
|
||||
.unwrap_or_default();
|
||||
let paused = setting(pool, "paused").await?.as_deref() == Some("1");
|
||||
Ok(Settings {
|
||||
refresh_interval_seconds,
|
||||
file_sort,
|
||||
paused,
|
||||
})
|
||||
Ok(Settings { file_sort, paused })
|
||||
}
|
||||
|
||||
/// (id, project_id, relative_path, kind, format, size, modifié le, manquant, erreur, non-lus)
|
||||
@@ -123,19 +115,23 @@ type FileRow = (
|
||||
/// Projets, fichiers et compteurs de non-lus.
|
||||
///
|
||||
/// Un fichier manquant ou un projet introuvable sur le disque ne compte aucun non-lu, ni un
|
||||
/// log d'accès (cf. [`LogFormat::notifies`]).
|
||||
/// log d'accès (cf. [`LogFormat::notifies`]). Les fichiers masqués (trop anciens, cf.
|
||||
/// [`is_hidden`]) ne sont ni listés ni comptés.
|
||||
pub async fn load_summary(pool: &SqlitePool) -> sqlx::Result<Summary> {
|
||||
type ProjectRow = (
|
||||
i64,
|
||||
String,
|
||||
String,
|
||||
i64,
|
||||
Option<i64>,
|
||||
String,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
Option<String>,
|
||||
);
|
||||
let projects: Vec<ProjectRow> = sqlx::query_as(
|
||||
"SELECT id, name, root_path, log_dirs, last_error, vhost_path, vhost_error
|
||||
"SELECT id, name, root_path, refresh_seconds, hide_after_days, log_dirs, last_error,
|
||||
vhost_path, vhost_error
|
||||
FROM projects ORDER BY name COLLATE NOCASE, id",
|
||||
)
|
||||
.fetch_all(pool)
|
||||
@@ -153,16 +149,32 @@ pub async fn load_summary(pool: &SqlitePool) -> sqlx::Result<Summary> {
|
||||
.fetch_all(pool)
|
||||
.await?;
|
||||
|
||||
let now = time::OffsetDateTime::now_utc().unix_timestamp();
|
||||
let mut summary = Summary {
|
||||
total: 0,
|
||||
now: time::OffsetDateTime::now_utc().unix_timestamp(),
|
||||
now,
|
||||
projects: Vec::with_capacity(projects.len()),
|
||||
};
|
||||
for (id, name, root_path, log_dirs, error, vhost_path, vhost_error) in projects {
|
||||
for (
|
||||
id,
|
||||
name,
|
||||
root_path,
|
||||
refresh_seconds,
|
||||
hide_after_days,
|
||||
log_dirs,
|
||||
error,
|
||||
vhost_path,
|
||||
vhost_error,
|
||||
) in projects
|
||||
{
|
||||
let project_ok = error.is_none();
|
||||
let files: Vec<FileSummary> = files
|
||||
let hide_after_days = hide_after_days.map(|d| d as u32);
|
||||
let (hidden, visible): (Vec<&FileRow>, Vec<&FileRow>) = files
|
||||
.iter()
|
||||
.filter(|f| f.1 == id)
|
||||
.partition(|f| is_hidden(f.6, now, hide_after_days));
|
||||
let files: Vec<FileSummary> = visible
|
||||
.into_iter()
|
||||
.map(
|
||||
|(fid, _, rel, kind, format, size, modified, missing, ferr, unread)| {
|
||||
let kind = LogKind::parse(kind).unwrap_or_default();
|
||||
@@ -190,6 +202,9 @@ pub async fn load_summary(pool: &SqlitePool) -> sqlx::Result<Summary> {
|
||||
id,
|
||||
name,
|
||||
root_path,
|
||||
refresh_seconds: refresh_seconds as u32,
|
||||
hide_after_days,
|
||||
hidden_files: hidden.len() as u32,
|
||||
log_dirs: parse_log_dirs(&log_dirs),
|
||||
error,
|
||||
vhost_path,
|
||||
|
||||
Reference in new issue
Block a user