++ fix statistiche campagne
- Dettaglio campagna: mostra tutti i territori conteggiati (stessa base della percentuale), non solo quelli assegnati dopo l'inizio. - Rientro: se più campagne corrispondono propone la più recente invece della prima creata; testo del banner chiarito. - Dettaglio campagna: nuova sezione "In corso" con i territori fuori durante la campagna e non ancora rientrati. - README: regola di conteggio documentata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,16 +18,27 @@ class CampagnaShow extends Component
|
||||
|
||||
public function render()
|
||||
{
|
||||
// Assignments counted for this campaign:
|
||||
// - assigned on or after campaign start
|
||||
// - linked to this campaign (campaign_id), regardless of returned_at (retroactive returns allowed)
|
||||
$conteggiate = Assegnazione::where('campaign_id', $this->campagna->id)
|
||||
->where('counted_in_campaign', true)
|
||||
->where('assigned_at', '>=', $this->campagna->start_date)
|
||||
// Assignments counted for this campaign: linked via campaign_id and
|
||||
// flagged as counted — the same set used by the percentage
|
||||
// (Campagna::percentuale_percorrenza). Which campaign is offered on
|
||||
// return is decided by Assegnazione::campagnaApplicabile().
|
||||
$conteggiate = $this->campagna->assegnazioniConteggiate()
|
||||
->with(['territorio', 'proclamatore'])
|
||||
->orderBy('returned_at')
|
||||
->get();
|
||||
|
||||
// Open assignments can still be counted for this campaign only while
|
||||
// no later campaign has started: on return the most recent one is
|
||||
// offered (see Assegnazione::campagnaApplicabile()).
|
||||
$superata = Campagna::where('start_date', '>', $this->campagna->start_date)
|
||||
->where('start_date', '<=', now()->toDateString())
|
||||
->exists();
|
||||
|
||||
$inCorso = $superata ? null : $this->campagna->assegnazioniInCorso()
|
||||
->with(['territorio', 'proclamatore'])
|
||||
->orderBy('assigned_at')
|
||||
->get();
|
||||
|
||||
// All assignments that were active during this campaign range
|
||||
$assegnateNelRange = Assegnazione::where('assigned_at', '<=', $this->campagna->end_date)
|
||||
->where(function ($q) {
|
||||
@@ -38,6 +49,7 @@ class CampagnaShow extends Component
|
||||
|
||||
return view('livewire.campagne.campagna-show', [
|
||||
'conteggiate' => $conteggiate,
|
||||
'inCorso' => $inCorso,
|
||||
'assegnateNelRange' => $assegnateNelRange,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user