refactor: update meta plugin to use output mappings
Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
@@ -10,7 +10,7 @@ pub struct DigestSha256MetaPlugin {
|
||||
hasher: Sha256,
|
||||
meta_name: String,
|
||||
item_id: Option<i64>,
|
||||
output_names: std::collections::HashMap<String, String>,
|
||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
||||
}
|
||||
|
||||
impl DigestSha256MetaPlugin {
|
||||
@@ -19,7 +19,7 @@ impl DigestSha256MetaPlugin {
|
||||
hasher: Sha256::new(),
|
||||
meta_name: "digest_sha256".to_string(),
|
||||
item_id: None,
|
||||
output_names: std::collections::HashMap::new(),
|
||||
outputs: std::collections::HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ impl MetaPlugin for DigestSha256MetaPlugin {
|
||||
let hex_string = format!("{:x}", hash_result);
|
||||
|
||||
// Save the hash as metadata using central output handler
|
||||
let _ = output_metadata(conn, item_id, &self.meta_name, hex_string, &self.output_names);
|
||||
let _ = self.save_meta(conn, item_id, "digest_sha256", hex_string);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -58,8 +58,8 @@ impl MetaPlugin for DigestSha256MetaPlugin {
|
||||
if let Some(outputs) = options.get("outputs") {
|
||||
if let Some(outputs_map) = outputs.as_mapping() {
|
||||
for (key, value) in outputs_map {
|
||||
if let (Some(key_str), Some(value_str)) = (key.as_str(), value.as_str()) {
|
||||
self.output_names.insert(key_str.to_string(), value_str.to_string());
|
||||
if let Some(key_str) = key.as_str() {
|
||||
self.outputs.insert(key_str.to_string(), value.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,8 +67,12 @@ impl MetaPlugin for DigestSha256MetaPlugin {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_output_name(&self, default_name: &str) -> String {
|
||||
self.output_names.get(default_name).cloned().unwrap_or_else(|| default_name.to_string())
|
||||
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
&self.outputs
|
||||
}
|
||||
|
||||
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
|
||||
self.outputs = outputs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +81,7 @@ impl MetaPlugin for DigestSha256MetaPlugin {
|
||||
pub struct ReadTimeMetaPlugin {
|
||||
start_time: Option<Instant>,
|
||||
meta_name: String,
|
||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
||||
}
|
||||
|
||||
impl ReadTimeMetaPlugin {
|
||||
@@ -84,6 +89,7 @@ impl ReadTimeMetaPlugin {
|
||||
ReadTimeMetaPlugin {
|
||||
start_time: None,
|
||||
meta_name: "read_time".to_string(),
|
||||
outputs: std::collections::HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,6 +112,27 @@ impl MetaPlugin for ReadTimeMetaPlugin {
|
||||
fn meta_name(&mut self) -> String {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
||||
if let Some(outputs) = options.get("outputs") {
|
||||
if let Some(outputs_map) = outputs.as_mapping() {
|
||||
for (key, value) in outputs_map {
|
||||
if let Some(key_str) = key.as_str() {
|
||||
self.outputs.insert(key_str.to_string(), value.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
&self.outputs
|
||||
}
|
||||
|
||||
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
|
||||
self.outputs = outputs;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
@@ -113,6 +140,7 @@ pub struct ReadRateMetaPlugin {
|
||||
start_time: Option<Instant>,
|
||||
bytes_read: u64,
|
||||
meta_name: String,
|
||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
||||
}
|
||||
|
||||
impl ReadRateMetaPlugin {
|
||||
@@ -121,6 +149,7 @@ impl ReadRateMetaPlugin {
|
||||
start_time: None,
|
||||
bytes_read: 0,
|
||||
meta_name: "read_rate".to_string(),
|
||||
outputs: std::collections::HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,4 +173,25 @@ impl MetaPlugin for ReadRateMetaPlugin {
|
||||
fn meta_name(&mut self) -> String {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn configure(&mut self, options: &std::collections::HashMap<String, serde_yaml::Value>) -> Result<()> {
|
||||
if let Some(outputs) = options.get("outputs") {
|
||||
if let Some(outputs_map) = outputs.as_mapping() {
|
||||
for (key, value) in outputs_map {
|
||||
if let Some(key_str) = key.as_str() {
|
||||
self.outputs.insert(key_str.to_string(), value.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
&self.outputs
|
||||
}
|
||||
|
||||
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
|
||||
self.outputs = outputs;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user