Yes, like I thought, so I doubt that it will be an improvement over the
current state which looks like this:

## We want all projects that are NOT outside of the range, ie:
## 1.) End date is lower than the start date of the range.
## 2.) Start date is higher than the end date of the range.
## Therefore we generate all projects whose:
## 1.) Start date is smaller than the end date of the range.
## 2.) End date is larger than the start date of the range.
(dm getCurrent> (Sdate Edate)
   (solve
      (quote
         @Rng1 (cons NIL Edate)    # The first range
         @Rng2 (cons Sdate T)      # The second range
         (select (@Proj)
            ((sDate +Proj @Rng1) (eDate +Proj @Rng2)) # Search two indexes
in parallel
            (range @Rng1 @Proj sDate)                  # Check ranges
            (range @Rng2 @Proj eDate) ) )
      @Proj ) )

The above works, tested 100%, it looks like it's going to scan the whole
database though in the generate clauses, which means collect on id with
subsequent list filter is probably just as fast, or perhaps not?




On Tue, Dec 27, 2016 at 8:27 AM, Alexander Burger <a...@software-lab.de>
wrote:

> On Mon, Dec 26, 2016 at 11:19:02PM +0100, Henrik Sarvell wrote:
> > If I do the relations with the +UB index and put 2016-10-01 as the start
> > date and 2016-10-20 as the end date for a specific project, do I get that
> > project in my result set if I do the collect with sdate 2016-10-15 and
> end
> > date 2016-11-15?
>
> > > >    (rel sDate (+UB +Aux +Ref +Date) (eDate))
> > > >    (rel eDate (+Date))
> > > >
> > > > Then a 'collect' would find the range directly:
> > > >
> > > >    (collect 'sDate '+Proj (list Sdate Sdate) (list Edate Edate))
>
> No. Consider eDate and sDate as coordinates in a 2-dimensional space,
> where a
> project is a point in that space.
>
> So you need to collect all projects with sDate at least in the range
> (2016-10-01 . 2016-10-01) and eDate at least in the range
> (2016-10-20 . 2016-10-20) to include the above project.
>
> A collection with the ranges (2016-10-1 . 2016-10-31) and (2016-11-1 .
> 2016-11-30), for example, would return all projects which started in
> October AND
> ended in November 2016.
>
> The ranges are inclusive btw.
>
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to