Skip to content

Commit

Permalink
feat: only query for local users
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek committed Feb 21, 2024
1 parent b74a619 commit 111a7b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions includes/cli/class-data-backfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Newspack_Network;

use Automattic\Jetpack\VideoPress\Data;
use WP_CLI;

/**
Expand Down Expand Up @@ -112,6 +111,12 @@ private static function process_reader_registered( $start, $end, $live, $verbose
],
'fields' => [ 'id', 'user_email', 'user_registered' ],
'number' => -1,
'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
[
'key' => \Newspack_Network\Utils\Users::USER_META_REMOTE_SITE,
'compare' => 'NOT EXISTS',
],
],
]
);
if ( ! $verbose ) {
Expand Down Expand Up @@ -357,6 +362,4 @@ public static function data_backfill( $args, $assoc_args ) { // phpcs:ignore Gen
}
WP_CLI::line( '' );
}

// TODO: a script to run the above on all nodes of the network.
}
6 changes: 4 additions & 2 deletions includes/utils/class-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* Class to watch the user for updates and trigger events
*/
class Users {
const USER_META_REMOTE_SITE = 'newspack_remote_site';
const USER_META_REMOTE_ID = 'newspack_remote_id';

/**
* Gets an existing user or creates a user propagated from another site in the Network
Expand Down Expand Up @@ -48,8 +50,8 @@ public static function get_or_create_user_by_email( $email, $remote_site_url, $r
return $user_id;
}

update_user_meta( $user_id, 'newspack_remote_site', $remote_site_url );
update_user_meta( $user_id, 'newspack_remote_id', $remote_id );
update_user_meta( $user_id, self::USER_META_REMOTE_SITE, $remote_site_url );
update_user_meta( $user_id, self::USER_META_REMOTE_ID, $remote_id );

return get_user_by( 'id', $user_id );
}
Expand Down

0 comments on commit 111a7b4

Please sign in to comment.