Skip to content

Commit 2c4da3f

Browse files
romanetarsmarcet
authored andcommitted
fix: selection_status order mapping (#246)
Signed-off-by: romanetar <roman_ag@hotmail.com> Change-Id: Ia1626fb974c853712e50e616fb53931477b234c2 chore: add log for Presention:getSelectionStatus Change-Id: I0cae39abd4ef39b620c56e2ae991739de65cde24 fix: selection_status order fix Signed-off-by: smarcet@gmail.com <smarcet@gmail.com> Change-Id: I6c9295a38239258ebf93046dd8a42544cae9064d
1 parent 611cdbb commit 2c4da3f

2 files changed

Lines changed: 85 additions & 14 deletions

File tree

app/Models/Foundation/Summit/Events/Presentations/Presentation.php

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,8 @@ public function setAttendingMedia($attending_media)
935935
public function getSelectionStatus()
936936
{
937937

938+
Log::debug(sprintf("Presentation::getSelectionStatus presentation %s", $this->id));
939+
938940
$session_sel = $this->createQuery("SELECT sp from models\summit\SummitSelectedPresentation sp
939941
JOIN sp.list l
940942
JOIN sp.presentation p
@@ -955,19 +957,68 @@ public function getSelectionStatus()
955957
$selection = null;
956958
if (count($session_sel) == 1) {
957959
$selection = $session_sel[0];
960+
Log::debug
961+
(
962+
sprintf
963+
(
964+
"Presentation::getSelectionStatus presentation %s got selection %s",
965+
$this->id,
966+
$selection->getId()
967+
)
968+
);
958969
}
959970

960-
if($this->isPublished())
971+
if($this->isPublished()) {
972+
Log::debug
973+
(
974+
sprintf
975+
(
976+
"Presentation::getSelectionStatus presentation %s return %s ( is published ).",
977+
$this->id,
978+
Presentation::SelectionStatus_Accepted
979+
)
980+
);
981+
961982
return Presentation::SelectionStatus_Accepted;
983+
}
962984

963985
if (!$selection) {
986+
Log::debug
987+
(
988+
sprintf
989+
(
990+
"Presentation::getSelectionStatus presentation %s return %s ( not selected ).",
991+
$this->id,
992+
Presentation::SelectionStatus_Unaccepted
993+
)
994+
);
964995
return Presentation::SelectionStatus_Unaccepted;
965996
}
966997

967998
if ($selection->getOrder() <= $this->getCategory()->getSessionCount()) {
999+
Log::debug
1000+
(
1001+
sprintf
1002+
(
1003+
"Presentation::getSelectionStatus presentation %s return %s ( selection order is %s from %s ).",
1004+
$this->id,
1005+
Presentation::SelectionStatus_Accepted,
1006+
$selection->getOrder(),
1007+
$this->getCategory()->getSessionCount()
1008+
)
1009+
);
9681010
return Presentation::SelectionStatus_Accepted;
9691011
}
9701012

1013+
Log::debug
1014+
(
1015+
sprintf
1016+
(
1017+
"Presentation::getSelectionStatus presentation %s return %s ( default ).",
1018+
$this->id,
1019+
Presentation::SelectionStatus_Alternate
1020+
)
1021+
);
9711022
return Presentation::SelectionStatus_Alternate;
9721023
}
9731024

app/Repositories/Summit/DoctrineSummitEventRepository.php

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ public function getAllByPage(PagingInfo $paging_info, Filter $filter = null, Ord
125125
}
126126

127127
$query = $this->getEntityManager()->createQueryBuilder()
128-
->distinct("e")
129128
->select("e")
129+
->distinct(true)
130130
->from($this->getBaseEntity(), "e")
131131
->leftJoin(Presentation::class, 'p', 'WITH', 'e.id = p.id');
132132

@@ -552,22 +552,42 @@ protected function getOrderMappings()
552552
SQL,
553553
'published_date' => 'e.published_date',
554554
'is_published' => 'e.is_published',
555-
556555
'selection_status' => <<<SQL
557-
CASE
558-
559-
WHEN (ssp.order is not null and ssp.order <= c.session_count and sspl.list_type = 'Group' and sspl.list_class = 'Session' and sspl.category = e.category) OR e.published = 1 THEN 'accepted'
556+
CASE
557+
WHEN p is null THEN ''
558+
WHEN e.published = 1 OR EXISTS (
559+
SELECT ___sp331.id
560+
FROM models\summit\SummitSelectedPresentation ___sp331
561+
JOIN ___sp331.presentation ___p331
562+
JOIN ___p331.category ___pc331
563+
JOIN ___sp331.list ___spl331 WITH ___spl331.list_type = 'Group' AND ___spl331.list_class = 'Session'
564+
WHERE
565+
___p331.id = e.id
566+
AND ___sp331.collection = 'selected'
567+
AND ___sp331.order <= ___pc331.session_count
568+
) THEN 'accepted'
560569
WHEN e.published = 0 AND NOT EXISTS (
561-
SELECT ___sp31.id
562-
FROM models\summit\SummitSelectedPresentation ___sp31
563-
JOIN ___sp31.presentation ___p31
564-
JOIN ___sp31.list ___spl31 WITH ___spl31.list_type = 'Group' AND ___spl31.list_class = 'Session'
565-
WHERE ___p31.id = e.id
566-
AND ___sp31.collection = 'selected'
570+
SELECT ___sp332.id
571+
FROM models\summit\SummitSelectedPresentation ___sp332
572+
JOIN ___sp332.presentation ___p332
573+
JOIN ___sp332.list ___spl332 WITH ___spl332.list_type = 'Group' AND ___spl332.list_class = 'Session'
574+
WHERE ___p332.id = e.id
575+
AND ___sp332.collection = 'selected'
567576
) THEN 'rejected'
568-
WHEN ssp.order is not null and ssp.order > c.session_count and sspl.list_type = 'Group' and sspl.list_class = 'Session' and sspl.category = e.category THEN 'alternate'
577+
WHEN
578+
EXISTS (
579+
SELECT ___sp333.id
580+
FROM models\summit\SummitSelectedPresentation ___sp333
581+
JOIN ___sp333.presentation ___p333
582+
JOIN ___p333.category ___pc333
583+
JOIN ___sp333.list ___spl333 WITH ___spl333.list_type = 'Group' AND ___spl333.list_class = 'Session'
584+
WHERE
585+
___p333.id = e.id
586+
AND ___sp333.collection = 'selected'
587+
AND ___sp333.order > ___pc333.session_count
588+
) THEN 'alternate'
569589
ELSE 'pending'
570-
END
590+
END
571591
SQL,
572592
'selection_plan' => 'selp.name',
573593
/*

0 commit comments

Comments
 (0)