Code Duplication    Length = 21-21 lines in 2 locations

packages/sync/src/Replicastore.php 2 locations

@@ 51-71 (lines=21) @@
48
		return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->term_relationships" );
49
	}
50
51
	public function post_count( $status = null, $min_id = null, $max_id = null ) {
52
		global $wpdb;
53
54
		$where = '';
55
56
		if ( $status ) {
57
			$where = "post_status = '" . esc_sql( $status ) . "'";
58
		} else {
59
			$where = '1=1';
60
		}
61
62
		if ( null != $min_id ) {
63
			$where .= ' AND ID >= ' . intval( $min_id );
64
		}
65
66
		if ( null != $max_id ) {
67
			$where .= ' AND ID <= ' . intval( $max_id );
68
		}
69
70
		return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE $where" );
71
	}
72
73
	// TODO: actually use max_id/min_id
74
	public function get_posts( $status = null, $min_id = null, $max_id = null ) {
@@ 167-187 (lines=21) @@
164
		return $this->table_checksum( $wpdb->postmeta, Defaults::$default_post_meta_checksum_columns, 'meta_id', Settings::get_whitelisted_post_meta_sql(), $min_id, $max_id );
165
	}
166
167
	public function comment_count( $status = null, $min_id = null, $max_id = null ) {
168
		global $wpdb;
169
170
		$comment_approved = $this->comment_status_to_approval_value( $status );
171
172
		if ( $comment_approved !== false ) {
173
			$where = "comment_approved = '" . esc_sql( $comment_approved ) . "'";
174
		} else {
175
			$where = '1=1';
176
		}
177
178
		if ( $min_id != null ) {
179
			$where .= ' AND comment_ID >= ' . intval( $min_id );
180
		}
181
182
		if ( $max_id != null ) {
183
			$where .= ' AND comment_ID <= ' . intval( $max_id );
184
		}
185
186
		return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE $where" );
187
	}
188
189
	private function comment_status_to_approval_value( $status ) {
190
		switch ( $status ) {