BeWelcome / rox

:earth_africa: BeWelcome lets you share a place to stay, connect with travellers, meet up and find accommodation on your journey. It is and will always be a free, open source, non for profit, democratic community.
https://www.bewelcome.org
GNU General Public License v2.0
188 stars 54 forks source link

#248 Fetching spam activities with at least 0 minutes runtime (instead of only the ones longer than 1 day) #339

Open PLP-GTR opened 8 months ago

PLP-GTR commented 8 months ago

Heads up: I don't know if auto loader for has to be rebuild manually or the new class in src/Doctrine/Functions/TimestampDiff.php is automatically found.


I have changed the filter for the admin/spam activities (production link):

from

DATEDIFF(a.ends, a.starts) > 1

to

TIMESTAMPDIFF(MINUTE, a.starts, a.ends) >= 0

Result: image

When writing App\Doctrine\Functions\TimestampDiff I tried to stick to the instructions here: → https://www.doctrine-project.org/projects/doctrine-orm/en/2.17/cookbook/dql-user-defined-functions.html

The seemingly simpler approach to use DATEDIFF(a.ends, a.starts) >= 0 would have lead to the issue, that activities with an end time prior to the start time on the same day would show up. Although this shouldn't be possible at storage logic already, the "> 1" filter was preventing those from showing up, so I kept this logic.

image


Fixes #248

thisismeonmounteverest commented 8 months ago

@PLP-GTR Why not just remove the datediff? The original idea was to find all activities that have been created by a member that has been banned because of spamming and that lasted longer than a day. Issue #248 says just show all activities of banned members to remove them if necessary. No need to check anything else.

thisismeonmounteverest commented 8 months ago

@PLP-GTR Regarding the heads up: In the dev environment most of the times newly introduced classes are found automatically. In the few cases that doesn't help you need to call php bin/console cache:clear. (Which is also needed to create the cache on production.)

PLP-GTR commented 8 months ago

@PLP-GTR Why not just remove the datediff? The original idea was to find all activities that have been created by a member that has been banned because of spamming and that lasted longer than a day. Issue #248 says just show all activities of banned members to remove them if necessary. No need to check anything else.

Three reasons:

I can change the handling if you want, no problem. Let me update #248 and draft this pull request.