Skip to content

Conversation

@thomas-zahner
Copy link
Member

Previously the two statistics were treated separately. This especially lead to an invalid JSON output, where we showed two separate top-level objects which weren't separated with a comma. Clean up and remove unnecessary abstractions in the process.

Previous

{
  "total": 12,
  "successful": 8,
  "unknown": 0,
  "unsupported": 0,
  "timeouts": 0,
  "redirects": 0,
  "excludes": 4,
  "errors": 0,
  "cached": 0,
  "success_map": {},
  "error_map": {},
  "suggestion_map": {},
  "redirect_map": {},
  "excluded_map": {},
  "duration_secs": 0,
  "detailed_stats": false
}
{
  "host_statistics": {
    "endler.dev": {
      "cache_hit_rate": 0.0,
      "cache_hits": 0,
      "cache_misses": 1,
      "client_errors": 0,
      "median_request_time_ms": 72,
      "rate_limited": 0,
      "server_errors": 0,
      "status_codes": {
        "200": 1
      },
      "success_rate": 1.0,
      "successful_requests": 1,
      "total_requests": 1
    }
  }
}

New

{
  "total": 12,
  "successful": 8,
  "unknown": 0,
  "unsupported": 0,
  "timeouts": 0,
  "redirects": 0,
  "excludes": 4,
  "errors": 0,
  "cached": 0,
  "success_map": {},
  "error_map": {},
  "suggestion_map": {},
  "redirect_map": {},
  "excluded_map": {},
  "duration_secs": 0,
  "detailed_stats": false,
  "host_stats": {
    "endler.dev": {
      "total_requests": 1,
      "successful_requests": 1,
      "success_rate": 1.0,
      "rate_limited": 0,
      "client_errors": 0,
      "server_errors": 0,
      "median_request_time_ms": 87,
      "cache_hits": 0,
      "cache_misses": 1,
      "cache_hit_rate": 0.0,
      "status_codes": {
        "200": 1
      }
    }
  }
}

Previously the two statistics were treated separately.
This especially lead to an invalid JSON output, where we showed two
separate top-level objects which weren't separated with a comma.
Clean up and remove unnecessary abstractions in the process.
@thomas-zahner thomas-zahner requested a review from mre December 30, 2025 14:16
fn format(&self, _stats: ResponseStats) -> Result<Option<String>> {
Ok(None)
fn format(&self, _: OutputStats) -> Result<String> {
Ok(String::new())
Copy link
Member Author

Choose a reason for hiding this comment

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

Raw does not currently output anything at all on latest release. With the new big per-host feature, on master host statistics are shown as with Compact, but all other stats are hidden, I feel like this doesn't make sense? Is the purpose of the raw mode really to hide all output?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the purpose of the raw mode is that the output could be piped into another program for processing. As such, it should not apply any formatting. My current understanding is that we should only print the outcome of the link check itself in raw mode, because the stats would conflate the output and make parsing harder. (I don't suggest that users should parse the raw output, but rather that it could be done as a last resort in case there is no better way to do the data handling.)

Copy link
Member Author

Choose a reason for hiding this comment

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

My current understanding is that we should only print the outcome of the link check itself in raw mode

So you mean it should only print 🔍 1 Total (in 0s) ✅ 1 OK 🚫 0 Errors? That would be compact mode. (the default mode) Raw currently does not print anything at all (both with latest release and this PR), except the progress which has nothing to do with the output format.

I currently do not see any use in this raw mode. If the purpose is to print nothing at all, I think we could say that's the users responsibility. ( > /dev/null) Also the name doesn't make sense. Raw doesn't sound like "print nothing at all".

Copy link
Member

Choose a reason for hiding this comment

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

Raw currently does not print anything at al

Oh! My bad. That's certainly unexpected. In this case, your change makes sense. I don't know if it broke or if it has always been the case. Too lazy to check, but my hope is that it did something useful at some point. ^^ So the original idea of was "print all the check results without any special formatting; just 'plaintext'."

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I've just double-checked. It was introduced in 8c0a32d. Even back then final stats were hidden with raw mode. (format_stats returned None) The only difference was in the ResponseFormatter (write_response) which is used for printing progress (not the final result).

This is different by now. We now have mode to specify how progress formatting is done. (e.g. emoji)
Because of this I would like to fully remove raw mode. It serves no purpose except hiding the final output. But this equivalent with e.g. piping to /dev/null.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've created #1976

This PR retains the current behaviour of hiding the results. We can then discuss what to do about the raw format on the new issue.

@thomas-zahner thomas-zahner force-pushed the cleanup-host-stats-formatting branch from 96cf922 to 3903b26 Compare December 31, 2025 09:31
@thomas-zahner thomas-zahner force-pushed the cleanup-host-stats-formatting branch from 3903b26 to 483c88b Compare December 31, 2025 10:32
Copy link
Member

@mre mre left a comment

Choose a reason for hiding this comment

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

Big improvement.

@thomas-zahner
Copy link
Member Author

@mre Thanks for the review. During refactoring I forgot to use the host_stats option, now fixed in 5fb8fe3. Now I'm only confused about the raw mode, as mentioned in the other comment.

@mre
Copy link
Member

mre commented Jan 2, 2026

Yeah, my bad. It looks like raw mode is broken. See my other comment. The gist of it is, we can and should fix it and I'm okay with your change. 😊

@thomas-zahner thomas-zahner mentioned this pull request Jan 2, 2026
@thomas-zahner thomas-zahner merged commit 57299ea into lycheeverse:master Jan 2, 2026
7 checks passed
@mre mre mentioned this pull request Jan 2, 2026
@mre mre mentioned this pull request Jan 25, 2026
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