Code Duplication    Length = 21-21 lines in 2 locations

packages/sync/src/Replicastore.php 2 locations

@@ 42-62 (lines=21) @@
39
		// noop right now
40
	}
41
42
	public function post_count( $status = null, $min_id = null, $max_id = null ) {
43
		global $wpdb;
44
45
		$where = '';
46
47
		if ( $status ) {
48
			$where = "post_status = '" . esc_sql( $status ) . "'";
49
		} else {
50
			$where = '1=1';
51
		}
52
53
		if ( null != $min_id ) {
54
			$where .= ' AND ID >= ' . intval( $min_id );
55
		}
56
57
		if ( null != $max_id ) {
58
			$where .= ' AND ID <= ' . intval( $max_id );
59
		}
60
61
		return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE $where" );
62
	}
63
64
	// TODO: actually use max_id/min_id
65
	public function get_posts( $status = null, $min_id = null, $max_id = null ) {
@@ 158-178 (lines=21) @@
155
		return $this->table_checksum( $wpdb->postmeta, \Jetpack_Sync_Defaults::$default_post_meta_checksum_columns, 'meta_id', \Jetpack_Sync_Settings::get_whitelisted_post_meta_sql(), $min_id, $max_id );
156
	}
157
158
	public function comment_count( $status = null, $min_id = null, $max_id = null ) {
159
		global $wpdb;
160
161
		$comment_approved = $this->comment_status_to_approval_value( $status );
162
163
		if ( $comment_approved !== false ) {
164
			$where = "comment_approved = '" . esc_sql( $comment_approved ) . "'";
165
		} else {
166
			$where = '1=1';
167
		}
168
169
		if ( $min_id != null ) {
170
			$where .= ' AND comment_ID >= ' . intval( $min_id );
171
		}
172
173
		if ( $max_id != null ) {
174
			$where .= ' AND comment_ID <= ' . intval( $max_id );
175
		}
176
177
		return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE $where" );
178
	}
179
180
	private function comment_status_to_approval_value( $status ) {
181
		switch ( $status ) {