Fix issue with form analytics for submissions (#362)
* Password not working when Notion embed - Fixed (#360) * fix tests --------- Co-authored-by: formsdev <136701234+formsdev@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Forms\FormStatistic;
|
||||
use App\Models\Forms\FormSubmission;
|
||||
use App\Models\Forms\FormView;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -61,29 +60,6 @@ class CleanDatabase extends Command
|
||||
];
|
||||
});
|
||||
|
||||
// Form Submissions
|
||||
$this->line('Aggregating form submissions...');
|
||||
FormSubmission::select('form_id', DB::raw('DATE(created_at) as date'), DB::raw('count(*) as submissions'))
|
||||
->whereDate('created_at', '<=', now()->startOfDay())
|
||||
->orderBy('date')
|
||||
->groupBy('form_id', 'date')
|
||||
->get()->each(function ($row) use (&$finalData) {
|
||||
$key = $row->form_id.'-'.$row->date;
|
||||
if (isset($finalData[$key])) {
|
||||
$finalData[$key]['data']['submissions'] = $row->submissions;
|
||||
} else {
|
||||
$finalData[$key] = [
|
||||
'form_id' => $row->form_id,
|
||||
'date' => $row->date,
|
||||
'data' => [
|
||||
'views' => 0,
|
||||
'submissions' => $row->submissions,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if ($finalData) {
|
||||
$this->line('Storing aggregated data...');
|
||||
$created = 0;
|
||||
@@ -94,7 +70,7 @@ class CleanDatabase extends Command
|
||||
if ($found !== null) { // If found update
|
||||
$newData = $found->data;
|
||||
$newData['views'] = $newData['views'] + $row['data']['views'];
|
||||
$newData['submissions'] = $newData['submissions'] + $row['data']['submissions'];
|
||||
$newData['submissions'] = 0;
|
||||
$found->update(['data' => $newData]);
|
||||
$updated++;
|
||||
} else { // Otherwise create new
|
||||
|
||||
Reference in New Issue
Block a user