altis-core icon indicating copy to clipboard operation
altis-core copied to clipboard

Build wp altis post-sync CLI command

Open VlasicVojislav opened this issue 3 months ago • 3 comments

Description

We need to build a wp altis post-sync CLI command where projects can run our default actions and their own actions as well. List of our actions:

  • Flush object cache
  • Reindex elasticsearch if available
  • Truncate cavalcade logs in the DB

Potential customer actions:

  • Anonymize data
  • Truncate tables / data so the data set is smaller
  • Update options

Acceptance criteria

  • [ ] WP CLI command calls the action
  • [ ] Flush object cache is hooked to the action
  • [ ] Reindex elasticsearch is hooked to the action
  • [ ] Truncate cavalcade logs in the DB is hooked to the action
  • [ ] Our actions can be unhooked (they shouldn't be anonymous actions)
  • [ ] Document what our code does
  • [ ] Document some useful customer examples (turn off analytics, turn off automatic API calls, etc.)

Ready for Work Checklist

Is this ticket ready to be worked on? See the Play Book Definition of Ready

  • [x] Is the title clear?
  • [x] Is the description clear and detailed enough?
  • [x] Are acceptance criteria listed?
  • [x] Have any dependencies been identified? (Optional)
  • [x] Have any documentation/playbook changes been identified? (Optional)
  • [x] Is an estimate or time box assigned?
  • [x] Is a priority label assigned?
  • [ ] Is this ticket added to a milestone?
  • [x] Is this ticket added to an epic? (Optional)

Completion Checklist

Is this ticket done? See the Play Book Definition of Done

  • [ ] Has the acceptance criteria been met?
  • [ ] Is the documentation updated (including README)?
  • [ ] Do any code/documentation changes meet project standards?
  • [ ] Are automatic tests in place to verify the fix or new functionality?
  • [ ] Or are manual tests documented (at least on this ticket)?
  • [ ] Are any Playbook/Handbook pages updated?
  • [ ] Has a new module release (patch/minor) been created/scheduled?
  • [ ] Have the appropriate backport labels been added to the PR?
  • [ ] Is there a roll-out (and roll-back) plan if required?

VlasicVojislav avatar Sep 29 '25 16:09 VlasicVojislav

As I understand this, we'll just make an action hook available (e.g. altis.post-sync) that we will execute via wp altis post-sync at the end of the sync process.

add_action( 'altis.post-sync', 'my_custom_post_sync_tasks' );

function my_custom_post_sync_tasks() {
    // 1. Anonymizing data
    \WP_CLI::runcommand( 'user update --anonymize-names --batch' );

    // 2. Truncating data
    global $wpdb;
    $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}log_table" );

    // 3. Updating options
    update_option( 'maintenance_mode', 'off' );
}

jerico avatar Oct 02 '25 04:10 jerico

Wouldn't be better if we skip the data that is not needed instead of sync it and then delete it?

filter182 avatar Oct 02 '25 07:10 filter182

Hey team! Please add your planning poker estimate with Zenhub @ferschubert-hm @jerico @mikelittle @vladislavhmn @wisyhambolu

VlasicVojislav avatar Oct 15 '25 11:10 VlasicVojislav