-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Write console command to re-calculate counter aggregate value #71
Comments
It looks like this command can compute correct value: awk 'END {print NR-1}' storage/{username}-views > storage/{username}-views-count |
I believe $ echo -e "hello\nthere" > test.txt && wc -l test.txt
2 test.txt |
Try echo -e "hello\nthere\n" > test.txt && wc -l test.txt |
That puts two new lines at the end of the file. |
That's exactly how views are stored. We have a blank line on the end of the file. |
Does the following script using Perl's readdir() for listing the directory content hang? It shouldn't try to read the entire directory content at once. my $dir = "/app/storage";
opendir(my $dh, $dir) || die "Can't open $dir: $!";
while (my $f = readdir $dh) {
print "$dir/$f\n";
}
closedir $dh; Save it as perl filename.pl If it doesn't we can build upon that. If it hangs, we can consider fixing the user on each HTTP request. We can have a flag that determines if a certain username is fixed, and on each request we check if the flag exists. If it doesn't, we fix the user and create the flag. |
After fix (by @Brikaa) of counter reset because of the race condition (#66) we need to create console command which will re-calculate correct counter values. It should count lines in
storage/{username}-views
file and store them tostorage/{username}-views-count
.Something like:
But we should iterate thru all the usernames in the storage directory. There are many counter files, so
ls -la
is hanging for a long time.One more thing to ensure: we need to make
-1
fromwc -l
, because of the empty line at the end of file.The text was updated successfully, but these errors were encountered: