Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/extra_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ fn extract_field(field_name: Field, extra: &Value, fields: &[String], id: Id, tr
// If we at least got an existing but empty field, return an empty string.
// I think it's safe to treat it as such.
} else {
log::warn!("Fields are empty in {}: {:?}", id, empty_fields);
log::warn!("Fields are empty in {} ({}): {:?}", id, id.url(tracker), empty_fields);
Ok(String::new())
}
}
Expand Down Expand Up @@ -546,7 +546,7 @@ impl ExtraFields for Issue {
if !errors.is_empty() {
let id = Id::Jira(&self.key);
let report = error_chain(errors, Field::TargetRelease, fields, id, config);
log::warn!("The custom target releases failed in {}. Falling back on the standard fix versions field.", id);
log::warn!("The custom target releases failed in {} ({}). Falling back on the standard fix versions field.", id, id.url(config));

// Provide this additional information on demand.
log::debug!("{}", report);
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Document {
project.private_footnote,
);

templating::report_usage_statistics(&internal_stats);
templating::report_usage_statistics(&internal_stats, &tickets_for_internal);

let used_internal: Vec<&AbstractTicket> = tickets_for_internal
.into_iter()
Expand Down
22 changes: 18 additions & 4 deletions src/templating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl config::Section {
// If subsystems resulted in an error, print out some debugging information
// before quitting. The ticket ID is especially useful.
Err(e) => {
log::error!("Invalid subsystems field in ticket {}.", &ticket.id);
log::error!("Invalid subsystems field in ticket {} ({}).", &ticket.id, &ticket.url);
panic!("{}", e);
}
};
Expand Down Expand Up @@ -413,17 +413,31 @@ pub fn format_document(

/// Log statistics about tickets that haven't been used anywhere in the templates,
/// or have been used more than once. Log both as warnings.
pub fn report_usage_statistics(ticket_stats: &HashMap<Rc<TicketId>, u32>) {
pub fn report_usage_statistics(
ticket_stats: &HashMap<Rc<TicketId>, u32>,
tickets: &[&AbstractTicket],
) {
let url_map: HashMap<&Rc<TicketId>, &str> = tickets
.iter()
.map(|t| (&t.id, t.url.as_str()))
.collect();

let unused: Vec<String> = ticket_stats
.iter()
.filter(|&(_k, &v)| v == 0)
.map(|(k, _v)| Rc::clone(k).to_string())
.map(|(k, _v)| {
let url = url_map.get(k).copied().unwrap_or("unknown");
format!("{} ({})", k, url)
})
.collect();

let overused: Vec<String> = ticket_stats
.iter()
.filter(|&(_k, &v)| v > 1)
.map(|(k, _v)| Rc::clone(k).to_string())
.map(|(k, _v)| {
let url = url_map.get(k).copied().unwrap_or("unknown");
format!("{} ({})", k, url)
})
.collect();

if !unused.is_empty() {
Expand Down