Add support for targeting the last x messages in a query range.

/circle/inbox/grams/-5/-0 gets the last 5 messages from the inbox, nothing more.
Closes #643.
This commit is contained in:
Fang 2018-03-07 01:13:20 +01:00
parent 9c67754678
commit 95e35ce2c9
3 changed files with 45 additions and 14 deletions

View File

@ -1210,6 +1210,7 @@
?=(^ tal.u.ran.src)
::
?- -.u.tal.u.ran.src
$sd &
$da (gte now.bol +.u.tal.u.ran.src)
$ud ?& ?=(^ seq)
(gte u.seq +.u.tal.u.ran.src)
@ -1230,7 +1231,13 @@
:: fill in empty ranges to select all grams.
=. ran
?~ ran `[[%ud 0] `[%ud count]]
?~ tal.u.ran `[hed.u.ran `[%ud count]]
=* hed hed.u.ran
=? hed ?=($sd -.hed)
[%ud (sub count (min count (abs:si +.hed)))]
?~ tal.u.ran `[hed `[%ud count]]
=* tal u.tal.u.ran
=? tal ?=($sd -.tal)
[%ud (sub count (min count (abs:si +.tal)))]
ran
:: never fails, but compiler needs it.
?> &(?=(^ ran) ?=(^ tal.u.ran))
@ -1240,12 +1247,14 @@
?: ?- -.u.tal.u.ran :: after the end
$ud (lth +.u.tal.u.ran num)
$da (lth +.u.tal.u.ran wen.i.gaz)
$sd !! :: caught above
==
:: if past the river, we're done searching.
zeg
?: ?- -.hed.u.ran :: before the start
$ud (lth num +.hed.u.ran)
$da (lth wen.i.gaz +.hed.u.ran)
$sd !! :: caught above
==
:: if before the river, continue onward.
$(num +(num), gaz t.gaz)
@ -1266,6 +1275,7 @@
?~ ran [& |]
=/ min
?- -.hed.u.ran
$sd & :: relative is always in.
$ud (gth count +.hed.u.ran)
$da (gth now.bol +.hed.u.ran)
==
@ -1273,6 +1283,7 @@
[min |]
=- [&(min -) !-]
?- -.u.tal.u.ran
$sd | :: relative is always done.
$ud (gte +(+.u.tal.u.ran) count)
$da (gte +.u.tal.u.ran now.bol)
==

View File

@ -66,10 +66,20 @@
|= ran/range
^- path
?~ ran ~
%+ welp
/(scot -.hed.u.ran +.hed.u.ran)
:- (place-to-knot hed.u.ran)
?~ tal.u.ran ~
/(scot -.u.tal.u.ran +.u.tal.u.ran)
[(place-to-knot u.tal.u.ran) ~]
::
++ place-to-knot
:> msg pointer to path component
:>
:> turns a place structure into a knot for use in
:> subscription paths.
::
|= pla/place
^- knot
?. ?=($sd -.pla) (scot -.pla +.pla)
(cat 3 '-' (scot %ud (abs:si +.pla)))
::
++ path-to-range
:> path to msg range
@ -80,18 +90,27 @@
|= pax/path
^- range
?~ pax ~
=/ hes/(unit place) (rush i.pax placer)
:: skip past non-number parts of path.
?: ?=({$~ $~} [(slaw %da i.pax) (slaw %ud i.pax)])
$(pax t.pax)
:+ ~
=+ hed=(slaw %da i.pax)
?^ hed [%da u.hed]
[%ud (slav %ud i.pax)]
?~ hes $(pax t.pax)
:+ ~ u.hes
?~ t.pax ~
:- ~
=+ tal=(slaw %da i.t.pax)
?^ tal [%da u.tal]
[%ud (slav %ud i.t.pax)]
(rush i.t.pax placer)
::
++ placer
:> parse a range place
;~ pose
(stag %ud dem:ag)
::
=- (stag %da (sear - crub:so))
|= a/dime
^- (unit @da)
?:(?=($da p.a) `q.a ~)
::
%+ stag %sd
%+ cook (cury new:si |)
;~(pfix hep dem:ag)
==
::
++ change-glyphs :< ...
::

View File

@ -55,6 +55,7 @@
++ place :> range indicators
$% {$da @da} :< date
{$ud @ud} :< message number
{$sd @sd} :< previous messages
== ::
++ prize :> query result
$% {$client prize-client} :< /client