Open sqs opened 1 year ago
Hmm, it might be that after:
and before:
got switched, since after:
shows no results (which is unexpected, since there are certainly results in the last 7 months!).
The natural date parser we use expects relative dates of the form "7 months ago". Based on a couple of tests, it appears to be tokenizing the 7
, failing to find the keyword ago
, and interpreting 7months
as 7:00 today
, which would explain why there doesn't seem to be any filtering going on with before
We used that package so we could move quickly, but we might eventually want to just write our own.
Can we instead use search query code intel so that the user hovers over the time string and sees the timestamp? Similar to what we do for eg. regex
This would also fix the ambiguity of timezone parsing (we always parse exact times as UTC if they don't have a timezone.
Ooh, that's a cool idea. I could definitely expose the date parsing via the API, then it would just be a matter of hooking up the hovers to call that
@camdencheek can we close this out now that you improved the semantics of 'before' in https://github.com/sourcegraph/sourcegraph/pull/61513?
I think this is still relevant. I just tried the search Quinn mentioned, and it still interprets 7months
incorrectly. I expect to fix this, we'd probably need to fork naturaldate
and update the parser.
Also, I do still think it would be helpful to have a hover that shows exactly how your relative time was interpreted. Especially since we interpret everything in UTC rather than local time. Right now, there is no real indication that your query isn't doing what you want it to except that you're getting commits that are more recent than you asked for.
In the query
file:featureflag type:diff before:7months
(which I was doing to see who to thank for building our feature flag system!), thebefore:
operator is not taking effect.The results include matches from 10 and 12 days ago. I expect no results newer than 7 months.
/cc @sourcegraph/search-product