Custom view counts not updating correctly

The issue was that the $query->set in the filter function was updating the main query used to count the number of posts. Likely due to the order in which they were called. I tried to flush and run a new wp_query but what ultimately worked best was the function below that uses a custom query.

public function count($director)
{ 
 $num = $this->wpdb->get_results("SELECT * FROM " . $this->wpdb->prefix . "postmeta WHERE meta_key = 'directory' AND meta_value="".$director."""); 
 return count($num); 
}