Code Duplication    Length = 21-21 lines in 2 locations

packages/sync/src/Replicastore.php 2 locations

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