Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 8
DedupDeathmatchChunk
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 8
 launch
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 7
 normalizeChunk
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
1<?php
2
3namespace Qmp\Laravel\Deduplication\Console\Commands;
4
5use Illuminate\Support\Collection;
6use Illuminate\Support\Facades\DB;
7use Illuminate\Support\Facades\Log;
8
9class DedupDeathmatchChunk extends BaseCommand
10{
11    /**
12     * The name and signature of the console command.
13     *
14     * @var string
15     */
16    protected $signature = 'dedup:deathmatch-chunk {sessionId}
17                                  {--skip= : How many records to skip}
18                                  {--take= : How many records to take}
19                                  {--throw-error : Throw errors if catch}';
20
21    /**
22     * The console command description.
23     *
24     * @var string
25     */
26    protected $description = 'Run dedup test on editor\'s files';
27
28    /**
29     * The disable message.
30     *
31     * @var string
32     */
33    protected $falseMessage = ['id' => 4, 'message' => 'Doublon Match à mort'];
34
35    /**
36     * Undocumented function
37     *
38     * @return void
39     */
40    protected function launch()
41    {
42        $this->aggregationResult = DB::connection("deduplicationMongo")
43            ->collection('sessions_data_temp_' . $this->argument('sessionId'))
44            ->skip((int) $this->option('skip'))
45            ->take((int) $this->option('take'))
46            ->get();
47
48        $this->process();
49    }
50
51    /**
52     * Undocumented function
53     *
54     * @param Collection $chunk
55     * @return Collection
56     */
57    protected function normalizeChunk(Collection $chunk): Collection
58    {
59        return $chunk->pluck('duplicates')->collapse();
60    }
61}