fix event record CONTINUOUS_DAYS rank
This commit is contained in:
@@ -348,10 +348,23 @@
|
||||
FROM `daily_stat` d
|
||||
JOIN `open_calendar` o ON d.`registeredDateValue` = o.`dateValue`
|
||||
),
|
||||
`customer_stat` AS (
|
||||
SELECT
|
||||
d.`customerId`,
|
||||
MAX(CASE WHEN d.`registeredDateValue` = #{todayDateValue} THEN 1 ELSE 0 END) AS `hasToday`
|
||||
FROM `daily_stat` d
|
||||
GROUP BY d.`customerId`
|
||||
),
|
||||
`anchor_date` AS (
|
||||
SELECT
|
||||
MAX(`openIndex`) AS `anchorOpenIndex`
|
||||
FROM `open_calendar`
|
||||
s.`customerId`,
|
||||
CASE
|
||||
WHEN s.`hasToday` = 1 THEN MAX(CASE WHEN c.`dateValue` = #{todayDateValue} THEN c.`openIndex` END)
|
||||
ELSE MAX(CASE WHEN c.`dateValue` < #{todayDateValue} THEN c.`openIndex` END)
|
||||
END AS `anchorOpenIndex`
|
||||
FROM `customer_stat` s
|
||||
CROSS JOIN `open_calendar` c
|
||||
GROUP BY s.`customerId`, s.`hasToday`
|
||||
),
|
||||
`continuous_stat` AS (
|
||||
SELECT
|
||||
@@ -361,7 +374,7 @@
|
||||
ELSE COUNT(1)
|
||||
END AS `recentContinuousEventDays`
|
||||
FROM `continuous_ordered` o
|
||||
JOIN `anchor_date` a
|
||||
JOIN `anchor_date` a ON o.`customerId` = a.`customerId`
|
||||
WHERE
|
||||
o.`openIndex` + o.`dayIndex` = a.`anchorOpenIndex` + 1
|
||||
<if test="eventIdList == null or eventIdList.size() != 1">
|
||||
|
||||
Reference in New Issue
Block a user