Closed mxstbr closed 7 years ago
Dang this bumps the size above 100 LoC, it's now 102 😢 need to fix that...
@@ master #4 diff @@
==========================================
Files 4 4
Lines 73 80 +7
Methods 13 15 +2
Messages 0 0
Branches 12 17 +5
==========================================
+ Hits 68 75 +7
Misses 5 5
Partials 0 0
Powered by Codecov. Last update e899065...e3c55ba
We're also missing the ability to do before
and after
at the same time! Need to fit that in somehow...
I think Before/After are good too. Go with that.
The code looks fine as it is.
I do think, however, the API could be better. (going with before/after) I think that ?before
and ?after
should be supported for both endpoints types (all/count). With the understood downside that it's not as performant of a query. But I think the primary reason most people would use get time-segments is to get the counts between those times. So providing it in the GET count-based requests requires no extra work to get the details. The usefulness of ?all is primarily targeted at some form of more advanced interface like a UI or CLI to handle calculations for the user.
I also think that you should support the combination of ?after={time}&before={time}
in which should
return m.time < before && m.time > after;
Added support for specifying both before
and after
. Not sure what you mean by this being support for both endpoints? What's the use of supporting /path?before=123
?
Should we return an error if before
and after
are the wrong way around, i.e. if before < after
, instead of just returning nothing?
I think an error would be fine for that.
So, I don't actually know why anyone would use ?before
by itself. But it comes pretty cheap to support if they did.
It's already supported 😉 will change to an error!
I'm not sure you should filter in the API itself. You should filter in the db.js file, so we can implement another db with filtering later.
I tend to agree @luisrudge
I actually agree @luisrudge, but that's out of scope for this PR I think. If we do that, we also have to move the filtering of the keys to db.js
and fix the whole testing setup.
Let's ship this for now and rework in another PR when we introduce database adapters?
Is the PR going to support the before & after on GET?
Is the PR going to support the before & after on GET?
It doesn't currently, what's the use? GET /id
will always just return a single view...
Yeah I didn't quite get that 😉 would you mind elaborating? Where do you want to see it supported?
ha, I'll try again
So my thought process is, what is the benefit from using ?all
? It's to get the detailed timing of events. But I don't think people will commonly use it for the detail that it provides. I think people would use it to figure out the total views in a time segments. That is because, as time goes on, GET + ?inc=false
becomes less useful. So people will fall back to having to do ?all
and then have to add logic to do the counts of views.
With that, I think if GET + ?inc=false
is used the user should be able to get the views count AND have the option to submit before
and after
time segments. It would just make the experience of that endpoint remain useful as time goes on.
So the result of this work would be, you can use ?before={time}
, ?after={time}
, or ?before={time}&after={time}
on the ?all
endpoint and the GET + ?inc=false
endpoint. Allowing for quick aggregated stats on the GET + ?inc=false
that can be time scoped. And more advanced results for ?all
that can also be scoped.
Does that resonate better?
Good call, I totally forgot about ?inc=false
! I think we might need to do this as part of #8, as doing it in core now and then moving that over will be a lot harder...
Closing in favor of landing #14!
Closes #3, cc @sean-roberts