title: How to get total number of rows in a drupal view alter hook?
body: <p>I've to avoid duplicate search result in a view, so what I am trying to alter the view using pre render hook. and removing the duplicates it's working fine but the problem is in the count of result. it shows the count from the query executed and this include the duplicated item too. also, I enabled the pagination with limit of 5 in a page. then the count seems to be strange it's taking the count of the elements showing in each page</p>
  
  <pre><code>function search_helper_views_pre_render(\Drupal\views\ViewExecutable $view) {
      if ($view-&gt;id() == "all_news" || $view-&gt;id() == "all_publications" || $view-&gt;id() == "all_events" || $view-&gt;id() == "global_search") {
        $unique_nids = $d_nids = $new_results = array();
  
        // Loop through results and filter out duplicate results.
        foreach($view-&gt;result as $key =&gt; $result) {
          if(!in_array($result-&gt;nid, $unique_nids)) {
            $unique_nids[] = $result-&gt;nid;
          }
          else {
            unset($view-&gt;result[$key]);
          }
        }
  
        $view-&gt;total_rows = count($view-&gt;result);
        //$view-&gt;pager-&gt;total_items = count($view-&gt;result);
        $view-&gt;pager-&gt;updatePageInfo();
    }
  }
  </code></pre>
  
  <p>the expected output of the $view->total_rows must be the total count of result instead of count of elements shown in the page.</p>