meeting-room-booking-system / mrbs-code

MRBS application code
Other
126 stars 62 forks source link

Cleaning up database to remove old bookings #3357

Open jberanek opened 1 year ago

jberanek commented 1 year ago

Hello brilliant folks,

First off, I wish you a very Happy New Year and lall the best to MRBS!

Second, please forgive me if this is a trivial question but I guess I never paid attention to this issue since I first started with MRBS 1.4.x

Third, this is not a bug but just a question from an old timer having his brain washed out to start the new year.

I just happened to realize that our current MRBS database size is increasing a lot and I just can't figure if there's any tool/config param or else to tackle this basic question....

I just looked at the tables and figured that I could probably do some sql delete on both mrbs_repeat and mrbs_entry based on year(timestamp) for instance but before I start hacking something which already exists somewhere, I thought I'd better first ask :-)

Thanks to let me know.

Best regards from Paris,

Philippe

Reported by: *anonymous

Original Ticket: mrbs/support-requests/2672

jberanek commented 1 year ago

The easiest thing to do is to do it through MRBS itself. Make sure you have $auth['show_bulk_delete'] = true; set in your config file, then login to MRBS as an admin and go to the Report page. Then run a report selecting all those entries you want to delete, eg all for a particular year. You should then see a button "Delete entries" at the bottom of the page. Be careful though, it can't be undone, so you might want to take a backup first.

The other thing to look out for is the sessions table which will grow very large if your PHP gc probability is set to zero.

Original comment by: campbell-m

jberanek commented 1 year ago

Hello Campbell,

Thx for the info. Wasn't aware of this parameter Just one comment about this: Having about 45000 entries to delete, I think that it would maybe nice to see a wait cursor or a message line indicating that the operation is ongoing and maybe disable the Delete button while the process is running...

Cheers,

Philippe

Original comment by: *anonymous

jberanek commented 1 year ago

And speaking of the sessions table which is - you're right - quite important, is there a simple way to decode the access field or else in order to filter out what has to be deleted? Thx

Original comment by: *anonymous

jberanek commented 1 year ago

'access' is just a POSIX/Unix timestamp https://www.epochconverter.com/ https://en.wikipedia.org/wiki/Unix_time

Original comment by: jberanek

jberanek commented 1 year ago

I'd recommend though letting PHP's garbage collector do the work if you can rather than deleting rows manually. As long as the gc probability is non-zero, the rows will eventually be deleted automatically.

Original comment by: campbell-m

jberanek commented 1 year ago

I think that it would maybe nice to see a wait cursor or a message line indicating that the operation is ongoing and maybe disable the Delete button while the process is running...

Good idea. I've now added a progress bar and a Cancel button in 9c4c4d.

Original comment by: campbell-m

jberanek commented 1 year ago

I've now added a comment in 53538b5.

Original comment by: campbell-m