I fixed the year problem. Can you check if it's still bugging out for you? I can't seem the recreate the bug which causes the stats to not load. If you still have that problem, do you know how to check your browser's console for errors?
I fixed the year problem. Can you check if it's still bugging out for you? I can't seem the recreate the bug which causes the stats to not load. If you still have that problem, do you know how to check your browser's console for errors?
Which bug? The bug that doesn't load or the year problem?
Hey Tony in the console error there is only two warnings (but I doubt that they are related). I posted a screenshot for you anyways.Happy to do more debugging
Ok, so I definitely could not see an interesting JS error in the console. but here are my observations.
You will only be able to re-generate this bug, by going to stats from Create -> click Stats button of one of the series. and then it will open the Stats page directly as the first load
The auto-selected Stats will be "Valid Reads" (charts colored in blue) , if you click on the Gained then it says "loading chart"
Click on other tabs e.g Glossary, Table of Contents.. and go back to the statistics tab, the "Gained" will be auto-selected and the numbers will show correctly!
Minor note: If you click on "Valid Reads" after navigating to other tabs, the chart will show in red instead of blue, but it doesn't matter.
It has always happened for me since I joined the platform.
Click the Month button, change to Year and back to month.
Then It'll load (It still flickers back to Year occasionally though... But works)
Hey Tony in the console error there is only two warnings (but I doubt that they are related). I posted a screenshot for you anyways.Happy to do more debugging
Ok, so I definitely could not see an interesting JS error in the console. but here are my observations.
You will only be able to re-generate this bug, by going to stats from Create -> click Stats button of one of the series. and then it will open the Stats page directly as the first load
The auto-selected Stats will be "Valid Reads" (charts colored in blue) , if you click on the Gained then it says "loading chart"
Click on other tabs e.g Glossary, Table of Contents.. and go back to the statistics tab, the "Gained" will be auto-selected and the numbers will show correctly!
Minor note: If you click on "Valid Reads" after navigating to other tabs, the chart will show in red instead of blue, but it doesn't matter.
It has always happened for me since I joined the platform.
Click the Month button, change to Year and back to month.
Then It'll load (It still flickers back to Year occasionally though... But works)
@Tony I found 1 more thign related to the bug- it seems that when you use the workaround the old points are still active, just invisible. What I mean is that the flicker between yearly and monthly gained readers is due to hovering over a data point from the other period (that is if I'm in year tab, and move mouse over the space where monthly readers gained would be displayed, it switches to year, and then switches back If i do the same but for yearly tab datapoint, but name in the dropdown stays the same)
The admin-ajax.php is not being called on the initial click, this could be the issue.
The expected function should be that jquery would be calling admin-ajax with the proper POST parameters, for example, this:
After a bit of investigation, I have found that openTab(e, s) in fact doesn't actually call rd_gained(o), not a single mention of it and the only method that actually calls rd_gained(o) is the switch tag on the HTML side which is why the graph loads when switching from Year to Month. This could (and maybe is) the issue.
This code is rewritten a bit so I can understand it easier, original is the one below.
JavaScript:
// The original code.
function openTab(e, s) {
"tab_r_validreads" == s && "yes" != $("#vr_loaded").val() && vr_gained("month"), $(".tab_sh_rcontent").hide(), $(".tab_sh_rlinks").removeClass("active"), document.getElementById(s).style.display = "block", $(e.currentTarget).addClass("active")
}
// A little bit cleaner look of the original code.
function openTab(e, s) {
"tab_r_validreads" == s && "yes" != $("#vr_loaded").val() && vr_gained("month"); // It only calls for vr_gained which is valid reads.
$(".tab_sh_rcontent").hide();
$(".tab_sh_rlinks").removeClass("active");
document.getElementById(s).style.display = "block";
$(e.currentTarget).addClass("active");
}
// An updated expected solution is shown in the next post.
// And also explains the issue in a bit more detail.
To add: #rg_loaded's value is always false unless you change option to Year (which would then trigger rd_gained("year") and changes the #rg_loaded to yes which makes me a bit sure that the issue really lies on openTab.
I wonder if you forgot about the function for it? (or I could be wrong, all in all, this is my speculation after a ten minute debug.
(unrelated but noticed, $.post(...) makes ajax posts easier and also jQuery.parseJson(...) is deprecated for JSON.parse(...) )
(This post is separated from the one at the top because the post would be too large, I want to keep them as organized as possible).
Since I couldn't replicate the scenario with official means, I decided to replicate it in a different manner, here is what I have in essence.
Think of execute(s) is opentab(e, s) which would determine which method to use depending on the condition, in the current version of the script, the function only calls for vr_gained, the code won't trigger rd_gained(o) because there is no condition for it as seen on the second picture.
A simple solution to this issue is to simply add a check and trigger if s is tab_r_gained which is the trigger word for reader gains.
And after changing up the code, it woud look like this.
JavaScript:
// A little change to make it into a one-liner.
function openTab(e, s) {
// This calls for either vr_gained or rd_gained depending on the conditions.
"tab_r_validreads" == s && "yes" != $("#vr_loaded").val() && vr_gained("month") || "tab_r_gained" == s && "yes" != $("#rg_loaded").val() && rd_gained("month");
$(".tab_sh_rcontent").hide();
$(".tab_sh_rlinks").removeClass("active");
document.getElementById(s).style.display = "block";
$(e.currentTarget).addClass("active");
}
which would then allow these two results.
Well, that's all I have after investigating for a while. I hope this helps out in fixing this bug (which has been here for literal months since reader gains function was added *cough*, I normally wouldn't delve much into this if it didn't make me curious over what was causing this issue).
Ok, so I definitely could not see an interesting JS error in the console. but here are my observations.
You will only be able to re-generate this bug, by going to stats from Create -> click Stats button of one of the series. and then it will open the Stats page directly as the first load
The auto-selected Stats will be "Valid Reads" (charts colored in blue) , if you click on the Gained then it says "loading chart"
Click on other tabs e.g Glossary, Table of Contents.. and go back to the statistics tab, the "Gained" will be auto-selected and the numbers will show correctly!
Minor note: If you click on "Valid Reads" after navigating to other tabs, the chart will show in red instead of blue, but it doesn't matter.
It has always happened for me since I joined the platform.
Click the Month button, change to Year and back to month.
Then It'll load (It still flickers back to Year occasionally though... But works)
@Tony I found 1 more thign related to the bug- it seems that when you use the workaround the old points are still active, just invisible. What I mean is that the flicker between yearly and monthly gained readers is due to hovering over a data point from the other period (that is if I'm in year tab, and move mouse over the space where monthly readers gained would be displayed, it switches to year, and then switches back If i do the same but for yearly tab datapoint, but name in the dropdown stays the same)
The admin-ajax.php is not being called on the initial click, this could be the issue.View attachment 6682
The expected function should be that jquery would be calling admin-ajax with the proper POST parameters, for example, this:View attachment 6683
After a bit of investigation, I have found that openTab(e, s) in fact doesn't actually call rd_gained(o), not a single mention of it and the only method that actually calls rd_gained(o) is the switch tag on the HTML side which is why the graph loads when switching from Year to Month. This could (and maybe is) the issue.
This code is rewritten a bit so I can understand it easier, original is the one below.
JavaScript:
// The original code.
function openTab(e, s) {
"tab_r_validreads" == s && "yes" != $("#vr_loaded").val() && vr_gained("month"), $(".tab_sh_rcontent").hide(), $(".tab_sh_rlinks").removeClass("active"), document.getElementById(s).style.display = "block", $(e.currentTarget).addClass("active")
}
// A little bit cleaner look of the original code.
function openTab(e, s) {
"tab_r_validreads" == s && "yes" != $("#vr_loaded").val() && vr_gained("month"); // It only calls for vr_gained which is valid reads.
$(".tab_sh_rcontent").hide();
$(".tab_sh_rlinks").removeClass("active");
document.getElementById(s).style.display = "block";
$(e.currentTarget).addClass("active");
}
// An updated expected solution is shown in the next post.
// And also explains the issue in a bit more detail.
To add: #rg_loaded's value is always false unless you change option to Year (which would then trigger rd_gained("year") and changes the #rg_loaded to yes which makes me a bit sure that the issue really lies on openTab.
I wonder if you forgot about the function for it? (or I could be wrong, all in all, this is my speculation after a ten minute debug.
(unrelated but noticed, $.post(...) makes ajax posts easier and also jQuery.parseJson(...) is deprecated for JSON.parse(...) )
(This post is separated from the one at the top because the post would be too large, I want to keep them as organized as possible).
Since I couldn't replicate the scenario with official means, I decided to replicate it in a different manner, here is what I have in essence.
Think of execute(s) is opentab(e, s) which would determine which method to use depending on the condition, in the current version of the script, the function only calls for vr_gained, the code won't trigger rd_gained(o) because there is no condition for it as seen on the second picture. View attachment 6688 View attachment 6689
A simple solution to this issue is to simply add a check and trigger if s is tab_r_gained which is the trigger word for reader gains. View attachment 6690
And after changing up the code, it woud look like this.
JavaScript:
// A little change to make it into a one-liner.
function openTab(e, s) {
// This calls for either vr_gained or rd_gained depending on the conditions.
"tab_r_validreads" == s && "yes" != $("#vr_loaded").val() && vr_gained("month") || "tab_r_gained" == s && "yes" != $("#rg_loaded").val() && rd_gained("month");
$(".tab_sh_rcontent").hide();
$(".tab_sh_rlinks").removeClass("active");
document.getElementById(s).style.display = "block";
$(e.currentTarget).addClass("active");
}
Well, that's all I have after investigating for a while. I hope this helps out in fixing this bug (which has been here for literal months since reader gains function was added *cough*, I normally wouldn't delve much into this if it didn't make me curious over what was causing this issue).
Yeah, I can see that which is also fine since it decreases the time it takes to load the reader statistics, thanks for the hardwork! Thread can now be marked as resolved.