Where to store ratings?

I reply my own question. I think I figured it out how to do it in the file system after all.

1. Spam protection

To not get bots I use this as protection:

//forum.getkirby.com/t/kirby-recaptcha/4631

2. Blacklist control

  1. Check if the IP is in a childpage of /current-page/blacklist/*.
  2. If not in blacklist, add an IP + timestamp to the blacklist.
  3. Remove all IP addresses older than today from the blacklist.

That means that the only thing that is in the blacklist is IP numbers from today. One vote each day is acceptable.

3. Keep track of votes

Store a counter for each vote to keep track and be able to calculate an avarage etc.

1: 24
2: 40
3: 456
4: 76
5: 9

So just keep what’s needed and it could probably grow forever. Untested. What do you think?

@1n3JgKl9pQ6cUMrW

Interesting approach!

You step out of the Kirby file system and roll out your own. What I do fear is that large file.

Maybe it could work to build a folder tree like my revisions plugin (a kind of copy of the file structure) and save the filename by the IP, like 123.12.13.145.txt. It would find it very fast.

For a page it would look kind of like this:

123.12.13.145.txt
123.12.14.145.txt
123.12.15.145.txt

Update

If there is a need to cleanup the IP:s maybe the best approach is not after a day (time). Maybe it’s by a file number limit, like after 100 IP:s it starts to cleanup.

I’m considering making a combination of these two approaches and name the files without .txt so Kirby does not use them. They will that way be seen as attached files.