• Resolved knowitallninja

    (@knowitallninja)


    My database is hugely bloated by the badgeos-log-entry post in my wp-posts table of my wordpress database. I have a lot of users and so every time they achieve a badge this is adding a new entry which has made my database around 1GB in size right now.

    I presume these entries are important to retain? Is there anything that can be done about them at all? I have concerns as my site is growing fairly rapidly and obviously that will cause this to be come a major problem in time.

    edit: obviously badgeos is not the only reason for the large database but the huge number of entries are a concern.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Did you ever figure out what to do about this? I’m curious about the same thing, as we now have 160,000 log entries!

    Plugin Contributor Wooninjas

    (@wooninjas)

    Hello all,

    We will add option to disable log entries on our next upcoming update.

    Thread Starter knowitallninja

    (@knowitallninja)

    Hi,

    That sounds like good news. I have a couple questions, if you don’t mind:

    1) What is the impact of disabling the log entries?

    2) Will disabling the log entries delete them form my database? Or will I need to do that myself manually?

    Thanks

    Plugin Contributor Wooninjas

    (@wooninjas)

    Well, disabling the log entries will not allow badgeos to create new log entries to database. You can delete the existing entries from database in bulk by following the below steps:

    1. Goto wp-admin -> BadgeOS -> Log Entries
    2. Select all
    3. Select move to trash in action
    4. Click on apply, See screenshot
    5. Repeat the process to delete entries from trash. See screenshot.

    Thread Starter knowitallninja

    (@knowitallninja)

    Ok, thanks. What purpose are the log entries then? Is it just so you can manually check who got achievements from the backend? BY deleting them I presume my users won’t suddenly lose their achievments?

    With 160,000 log entries, that will take us a while, going page by page!

    Plugin Contributor Wooninjas

    (@wooninjas)

    @knowitallninja

    By deleting log entries, users won’t lose their achievements.

    Thread Starter knowitallninja

    (@knowitallninja)

    Ok thanks.

    Wouldn’t suppose you could advise on a query I could run in my database to clear these logs instead of using the log entry section of Badgeos? It’s taking a long time as I can only do them around 250 at a time from within WordPress.

    Either thanks for the help.

    @wooninjas, when do you expect the new version to be released? We have a site with 55k users and had to disable BadgeOS and delete the log entries because the site couldn’t keep up with the overhead.

    If the new version isn’t due out soon, can you direct me on how to manually edit the plugin code to disable log entries, or at the very least, disable the log entries for user login, which seem to be the most common ones?

    Thanks so much.

    Plugin Contributor Wooninjas

    (@wooninjas)

    We are about to release an updated version soon, however you can add below snippet to active theme’s functions.php file to disable log entries.

    /**
     * Disable Log Entries
     */
    add_action( 'init', function() {
        remove_filter( 'badgeos_post_log_entry', 'badgeos_log_entry', 10, 2 );
    } );

    Query to delete already added log entries:
    – Install wp-maximum-execution-time-exceeded plugin that will increase your server maximum execution time to 5 min
    – Add below snippet to active theme’s functions.php
    – Visit your website to run the query
    – After deleting all the log posts, remove this snippet from functions.php file
    – Delete wp-maximum-execution-time-exceeded plugin

    https://www.ads-software.com/plugins/wp-maximum-execution-time-exceeded/

    /**
     * Delete badgeos-log-entry post type data
     */
    add_action( 'init', function() {
        global $wpdb;
        $badgeos_log_entry = $wpdb->get_results( "SELECT <code>ID</code> FROM $wpdb->posts WHERE post_type = 'badgeos-log-entry';" );
        if( is_array( $badgeos_log_entry ) && !empty( $badgeos_log_entry ) && !is_null( $badgeos_log_entry ) ) {
            foreach( $badgeos_log_entry as $log_entry ) {
                $wpdb->query( "DELETE FROM $wpdb->posts WHERE ID = '$log_entry->ID';" );
                $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE post_id = '$log_entry->ID';" );
            }
        }
    } );

    Let us know how it goes.

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    • This reply was modified 7 years, 3 months ago by bdbrown.
    Thread Starter knowitallninja

    (@knowitallninja)

    Sadly that bit of code for deleting the log entries doesn’t seem to work for me at all.

    Would you know if I could send a query directly to my database in phpMyAdmin. I can figure out how to get rid of the entries in the posts table:

    DELETE FROM <<NAMEOFMYPOSTTABLE> WHERE post_type = ‘badgeos-log-entry’;

    But that would leave all the post_meta orphaned.

    Plugin Contributor Wooninjas

    (@wooninjas)

    You can use the following SQL query to delete all log entries and their metadata, please do make a backup before running this query.

    DELETE wp_posts FROM wp_posts
    INNER JOIN wp_postmeta
    ON wp_postmeta.post_id = wp_posts.ID
    where wp_posts.post_type = 'badgeos-log-entry';

    Or better to use the Bulk Delete plugin. Once installed, navigate to Dashboard – Bulk WP – Bulk Delete Posts, scroll down to metabox name By Custom Post Type select badgeos-log-entry and check Delete permanently

    Please take a backup of your database for both cases, we will not be responsible for any data loss.

    • This reply was modified 7 years, 2 months ago by Wooninjas. Reason: removing extra space
    • This reply was modified 7 years, 2 months ago by Wooninjas.

    The bulk delete plugin works well…you can set a “restrict to posts older than # days” in order to keep the last year’s data. The server may time out a lot, so you have to run it several times to get them all deleted.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Badgeos Log Entries’ is closed to new replies.