Mailing List Archive

Overlap calculation
Hi,

I was wondering in 1.1.6 why

SELECT rrule_event_overlaps(
'2018-01-23 18:00:01'::timestamp, -- dtstart
'2018-01-25 00:00:00'::timestamp, -- dtend
null, -- rrule
'2018-01-22 12:00:00'::timestamp, -- mindate
'2018-01-22 12:00:00'::timestamp -- maxdate
);

would return true, whereas setting dtstart to a minute beforehand returns false:

SELECT rrule_event_overlaps(
'2018-01-23 18:00:00'::timestamp, -- dtstart
'2018-01-25 00:00:00'::timestamp, -- dtend
null, -- rrule
'2018-01-22 12:00:00'::timestamp, -- mindate
'2018-01-22 12:00:00'::timestamp -- maxdate
);

Looking into the implementation, there is a short circuit:

IF repeatrule IS NULL THEN
RETURN (dtstart <= maxdate AND base_date >= mindate);
END IF;

In this particular constellation, this function flips when dtstart
goes from 2018-01-23 18:00:00 to 2018-01-23 18:00:01.

Is this behavior expected?

Thanks in advance,

Ben

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general
Re: Overlap calculation [ In reply to ]
On Mon, Jan 22, 2018 at 10:33 PM, Ben Hood <0x6e6562@gmail.com> wrote:
> IF repeatrule IS NULL THEN
> RETURN (dtstart <= maxdate AND base_date >= mindate);
> END IF;

I was wondering if it would make more sense to patch this branch like so:

IF repeatrule IS NULL THEN
event_range := tstzrange(dtstart, dtend);
constraint_range := tstzrange(in_mindate, in_maxdate);
IF isempty(constraint_range) THEN
RETURN event_range @> mindate;
ELSE
RETURN event_range @> constraint_range;
END IF;
END IF;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Davical-general mailing list
Davical-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/davical-general