feat(app): background collection frame for sites, search words and RSS feeds

Targets (none by default), interval and keep days on a new 백그라운드 수집 screen with the
results; the worker collects on its own thread through the web search's address check and
writes only to the data folder's collect/ (logs carry target names and counts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-13 21:29:49 +09:00
parent d531eb0ffc
commit b94e9dc112
15 changed files with 861 additions and 14 deletions

View File

@@ -281,6 +281,11 @@ impl AdminApi {
Ok(json!({"set": !value.is_empty(),
"restartNeeded": self.controller()?.state() == crate::control::State::Running}))
}
"collect_results" => {
let target = args.get("target").and_then(Value::as_str).filter(|t| !t.is_empty());
let limit = args.get("limit").and_then(Value::as_u64).unwrap_or(100).clamp(1, 500) as usize;
Ok(json!(crate::collect::results(self.dir()?.path(), target, limit)?))
}
"channel_sync_status" => Ok(Value::Object(self.syncer()?.status().into_iter()
.map(|(id, s)| (id.to_string(), json!(s))).collect())),
"discord_channel_info" => {
@@ -392,6 +397,22 @@ mod tests {
assert!(a.call("nope", json!({})).await.is_err());
}
#[tokio::test]
async fn collection_targets_are_saved_and_their_results_read_from_the_data_folder() {
let (a, base) = api("api-collect");
let data = base.join("d");
a.call("folder_choose", json!({"path": data.to_string_lossy()})).await.unwrap();
let targets = json!([{"name": "뉴스", "kind": "rss", "value": "https://feed.example/rss", "everyMinutes": 30}]);
a.call("settings_apply", json!({"changes": {"collect.targets": targets, "collect.keepDays": 7}})).await.unwrap();
assert_eq!(a.call("settings_view", json!({})).await.unwrap()["collect.targets"], targets);
let day = data.join("collect").join("뉴스");
std::fs::create_dir_all(&day).unwrap();
std::fs::write(day.join("2026-11-13.jsonl"), "{\"at\": \"2026-11-13T09:00:00+09:00\", \"title\": \"t\"}\n").unwrap();
let r = a.call("collect_results", json!({"target": null})).await.unwrap();
assert_eq!(r, json!([{"at": "2026-11-13T09:00:00+09:00", "title": "t", "target": "뉴스"}]));
assert!(a.call("collect_results", json!({"target": "../config"})).await.is_err());
}
#[tokio::test]
async fn mcp_values_are_stored_encrypted_shown_only_as_set_masked_in_logs_and_go_with_their_server() {
let (a, base) = api("api-mcp");