Automattic / WP-Job-Manager

Manage job listings from the WordPress admin panel, and allow users to post jobs directly to your site.
https://wpjobmanager.com
GNU General Public License v3.0
895 stars 366 forks source link

Add/stats log stat method #2728

Closed pgk closed 6 months ago

pgk commented 6 months ago

Fixes #2716

Changes Proposed in this Pull Request

Note:

I decided to do the stat update in one go by using ON DUPLICATE UPDATE. In order for duplicate to trigger, I introduced a unique index and I changed the stat table definition a bit for this. LMK if the new structure seems reasonable.

I crammed it all into the Stats class. They should probably live in separate classes eventually, but I think it is convenient for reading all the changes in one go and for not overengineering without reason.

The DB changes have testing implications. You probs need to drop the stats table entirely. dBdelta does not do a good job with handling e.g. the default field change or the unique index change.

TBD: Should we drop the other index entirely?

Testing Instructions

Release Notes

New or Updated Hooks and Templates

Deprecated Code

Screenshot / Video


Plugin build for 074eccb57c9466bc86b138ce7ea9207f9260f11b
📦 Download plugin zip
▶️ Open in playground
fjorgemota commented 6 months ago

LMAO I didn't saw that Peter just shared a review.

Nice :)