Stats 1.01
19 March 2022 11:28 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
I managed to notice the first serious bug in my AO3 stats script, when "High City on a Hill" failed to show up as having any new hits at all for the month of March.
Because awk handles all input as text by default, the values for the number of hits etc. are being saved as text strings instead of numeric values, which means that in a comparison "6" is treated as greater than "3", but "112" is treated as less than "31" (because "1" at the start of the 'word' is less than "3"). So if the difference between two values is sufficiently large for them to have a differing number of digits, the results of the comparison become entirely spurious :-p
The answer is to multiply all values which are intended to be numeric by 1, in order to ensure that awk knows to store (and compare) them as numbers and not strings!
Because awk handles all input as text by default, the values for the number of hits etc. are being saved as text strings instead of numeric values, which means that in a comparison "6" is treated as greater than "3", but "112" is treated as less than "31" (because "1" at the start of the 'word' is less than "3"). So if the difference between two values is sufficiently large for them to have a differing number of digits, the results of the comparison become entirely spurious :-p
The answer is to multiply all values which are intended to be numeric by 1, in order to ensure that awk knows to store (and compare) them as numbers and not strings!