Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commands: add source statistics to table output #225

Merged
merged 3 commits into from
Sep 11, 2023

Conversation

joe-prosser
Copy link
Contributor

@joe-prosser joe-prosser commented Sep 11, 2023

Optionally print num_comments when getting sources

@joe-prosser joe-prosser self-assigned this Sep 11, 2023
Copy link
Collaborator

@tommilligan tommilligan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, two minor comments

Comment on lines 48 to 62
sources
.iter()
.map(|source| {
info!("Getting statistics for source {}", source.full_name().0);
let stats = client
.get_source_statistics(
&source.full_name(),
&StatisticsRequestParams {
comment_filter: Default::default(),
},
)
.expect("Could not get statistics for source");
(source.id.clone(), stats)
})
.collect()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should raise error rather than expecting here, as per previous reviews:

Suggested change
sources
.iter()
.map(|source| {
info!("Getting statistics for source {}", source.full_name().0);
let stats = client
.get_source_statistics(
&source.full_name(),
&StatisticsRequestParams {
comment_filter: Default::default(),
},
)
.expect("Could not get statistics for source");
(source.id.clone(), stats)
})
.collect()
sources
.iter()
.map(|source| {
info!("Getting statistics for source {}", source.full_name().0);
let stats = client
.get_source_statistics(
&source.full_name(),
&StatisticsRequestParams {
comment_filter: Default::default(),
},
)
.context("Could not get statistics for source")?;
Ok((source.id.clone(), stats))
})
.collect()?

or something like this

if let Some(stats) = &self.stats {
stats.num_comments.to_string()
} else {
"N/A".to_string()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with above?

Suggested change
"N/A".to_string()
"none".dimmed()

@joe-prosser joe-prosser merged commit e8af1bd into master Sep 11, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants