diff --git a/src/Ushahidi/Modules/V3/Repository/Form/StatsRepository.php b/src/Ushahidi/Modules/V3/Repository/Form/StatsRepository.php index f145d8f223..24d725f69d 100644 --- a/src/Ushahidi/Modules/V3/Repository/Form/StatsRepository.php +++ b/src/Ushahidi/Modules/V3/Repository/Form/StatsRepository.php @@ -318,7 +318,7 @@ public function getResponseRecipients($form_id, $created_after, $created_before) ->from('posts') ->where('form_id', '=', $form_id); $query = $this->betweenDates($query, 'created', $created_before, $created_after); - $query = DB::select([DB::expr('COUNT(contact_id)'), 'total']) + $query = DB::select([DB::expr('COUNT(messages.contact_id)'), 'total']) ->distinct(true) ->from([$query,'targeted_posts']) ->join('messages', 'INNER') diff --git a/src/Ushahidi/Modules/V5/Repository/Survey/EloquentSurveyStatesRepository.php b/src/Ushahidi/Modules/V5/Repository/Survey/EloquentSurveyStatesRepository.php index fcc30c4fd8..fde0b068f1 100644 --- a/src/Ushahidi/Modules/V5/Repository/Survey/EloquentSurveyStatesRepository.php +++ b/src/Ushahidi/Modules/V5/Repository/Survey/EloquentSurveyStatesRepository.php @@ -176,7 +176,7 @@ private function queryForWeb($survey_id, $created_after, $created_before) public function getResponseRecipients($survey_id, SurveyStatesSearchFields $search_fields) { $query = DB::table('posts') - ->selectRaw('COUNT(contact_id) as total') + ->selectRaw('COUNT(messages.contact_id) as total') ->distinct() ->join('messages', 'messages.post_id', '=', 'posts.id') ->where('form_id', '=', $survey_id)