LittleBigThing / carbon-footprint

A WordPress plugin to spread awareness about the carbon footprint of websites and to help making WordPress sites become more sustainable. The information is based on data from the Website Carbon Calculator.
GNU General Public License v2.0
5 stars 0 forks source link

Check if test is working properly with cron #6

Open LittleBigThing opened 1 year ago

LittleBigThing commented 1 year ago

The carbon footprint test should take place in two ways:

  1. when the Site Health page is visited
  2. during Site Health's cron job

I am currently verifying whether the test is working correctly (it should I think) during cron. More information soon.

LittleBigThing commented 10 months ago

In version 1.1, I’ve fixed loading the class and helper file for the test to not only load in the admin (deleted the is_admin() check), and that seems to fix the test not running during wp-cron. If there are any problems, please share them here. :-)

LittleBigThing commented 10 months ago

I noticed that when the transient is set due to the test running during cron, the dashboard widget for homepages worse than 90% of pages tested is not shown. This is logical as designed right now (code to save data for widget does not run during cron...), but not correct.

LittleBigThing commented 4 months ago

Worked on this one. Some more testers would be great! Got a 503 error from the API last time, so still testing.

LittleBigThing commented 4 months ago

I'm tagging you @alokstha1 if you're interested, don't feel obligated though. :-)

alokstha1 commented 3 months ago

@LittleBigThing May I ask what are the test cases?

Installed on a test site and got the below response.

Screenshot 2024-03-11 at 9 39 23 pm

Does this mean that No. 1 from https://github.com/LittleBigThing/carbon-footprint/issues/6#issue-1760282635 is passed?

LittleBigThing commented 3 months ago

Yes, thanks @alokstha1! :-) I am glad to see the rating appearing correctly. 👍 What do you think @yellowlimeNL?

Did you think it was easy to find out what the plugin would do? Have you noticed the banner after activation that prompts you to test the site using Site Health?

What I did to test 2. (above) was installing the Transients Manager and the Crontrol plugins:

So: I (first deactivated and then) activated the Carbon Footprint plugin and did not run Site Health. I checked and the transient carbonfootprint_test was not there. I then ran the cron job. If you wait a while (max. 30 sec), the transient appears in the list under Tools and if you then go to Site Health, the results of the carbon test should be there, without the usual delay, since the transient is used to show the results.

Could you check if this is also the case for you? I am not sure if everything goes well if the test is run for the first time for a large page. ‘First time’ meaning that the result is not cached by the plugin and neither by the API. I am not sure about the API, but I think it caches the result for 24h. The websitecarbon.com website does this for a longer period (but you can force it to re-test).

Thanks for any comments and testing! 🥇

YellowlimeNL commented 3 months ago

If you ask me about the info shown, the info seems to be rather complete (at this stage of development). One thing I should add is the score, in this case 'C'. I would mention the scale .e.g "...C, on a scale of A to XX."

LittleBigThing commented 3 months ago

If you ask me about the info shown, the info seems to be rather complete (at this stage of development). One thing I should add is the score, in this case 'C'. I would mention the scale .e.g "...C, on a scale of A to XX."

Good point, thanks! I link to the description of the scale, but that’s a complex description. I'll think about what is the best way to show it/put it in context, since it is not just the letters, but that is a good start.

Screenshot 2024-03-12 at 13 09 20
Nahuai commented 3 months ago

Yes, we should provide context to the grading, so adding the link and some text like "on a scale of A to F" (or similar) could be a good way to do it.

oldrup commented 1 month ago

Okay, I might be one of the few who actually find the Site Health feature really useful, so I know where it is and what it does, but even given that “bias”, I must say, I find the current implementation and explanation, spot on.

image

Should I point at something - the carbon rating link should in my opinion, have an external link indicator, like the other external links. Good sources btw, and not too much.

Is it understood correctly, that there is a dashboard widget, but that it's only available if the grading is bad? Why is that? I'd find it useful with a persistent widget showing the grade, reminding me to continue my work bringing the footprint down. A cached result is fine.

LittleBigThing commented 3 weeks ago

Thanks for the positive feedback! 💚

@oldrup: the plugin is intended to integrate smoothly with WP features, without disrupting things too much. It is a valid point though I think about the dashboard widget. I think I kind of based it on how the website carbon calculator and the site health feature work. When something is considered a critical error, it warns the user through the site health function already, so the widget is kind of an informative support to that (only displayed when the error is considered critical).

We could consider showing it for lower thresholds. Maybe another ticket to discuss that?

I am not sure I have mentioned this somewhere but I was planning to add a filter to enable modifying the threshold for generating a critical error (and thus showing the widget), but did not experiment enough with it yet. Also, the filter must probably have a lower end limit to ensure that it is not turned off that way completely (I realise that all site health features can be turned off using a filter, which is probably a good thing and fits WP's philosophy).