mirror of
https://github.com/antonkomarev/github-profile-views-counter.git
synced 2026-07-13 01:01:53 -04:00
Write console command to re-calculate counter aggregate value #47
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @antonkomarev on GitHub (Sep 3, 2023).
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}-viewsfile 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 -lais hanging for a long time.One more thing to ensure: we need to make
-1fromwc -l, because of the empty line at the end of file.@antonkomarev commented on GitHub (Sep 3, 2023):
It looks like this command can compute correct value:
@Brikaa commented on GitHub (Sep 3, 2023):
I believe
wc -ldoes not count the new line at the end of the file@antonkomarev commented on GitHub (Sep 3, 2023):
Try
@Brikaa commented on GitHub (Sep 3, 2023):
That puts two new lines at the end of the file.
@antonkomarev commented on GitHub (Sep 3, 2023):
That's exactly how views are stored. We have a blank line on the end of the file.
@Brikaa commented on GitHub (Sep 3, 2023):
Yes, but your example puts two blank lines at the end of the file.

@Brikaa commented on GitHub (Sep 15, 2023):
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.
Save it as
filename.pland run in the container it using: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.