So, this is a really niche issue, but here’s what I’m trying to do:
My app shows a VerticalList of posts which each contain a list of date ranges. I want the List to only show posts in which the current date is included in one of the ranges.
I know I can’t use “contains (point)” in the List filter, as each post has a list of ranges.
My workaround is shown here. Instead of filtering the posts in the entire List, I’m trying to put a when… condition on each ListItem, to make it invisible if it’s date ranges list (filtering for containing today) returns to 0.
I’ve tested this with example posts, but posts with date ranges that don’t contain today are still showing, that’s where I’m confused. Is this when condition incorrect?
Does each post have a date range? Is that it?
Can’t you have a start_date and end_date for each post? Something like this:
Search for Posts
constraints:
start_date ≤ Current date/time
end_date ≥ Current date/time
I’m not sure if that’s exactly what you mean. If not, could you explain it a little more so I can try to help?
Sure! Each post has multiple date ranges.
The niche issue is that, say one specific post has mutiple date ranges, some before the current date, and some after the current date, but none of the date ranges includes the current date, I don’t want that post/ListItem to be visible
I’ve already implemented what you’ve shown, but unfortunately that’s not specific enough for what I’m trying to achieve. The posts in my app are hosted, planned, events in the area. So if an event happens on Sunday, Monday, and Wednesday, I don’t want that post to show when the user views the app on Tuesday. The current solution (yours) would still show the event when viewed on Tuesday, since the start date is Sunday, and the end date is Wednesday.
Why a data range then on the post then? why not a list of dates or a list of days of the week and compare with current date or current day of week?
1 Like
Exactly, in this specific case, I think it would be better for @skyler.allen to have a list of specific dates when that post will be published rather than a date range.
It will be much easier for you to filter the results.
1 Like
Mmmmmmm I might have a solution here, I’ll go try that!
But to answer why a date range, my original thinking was to specify the start/end time if an event only takes one day (show opens at 7pm, ends at 10pm). I wanted to have the data for the start/end times, not just dates.
But I agree. I can extract just the dates for each range and put them into a list, and then use that list.
I’ll go try that and let yall know!
Mmmm
You can have another table called “EventOccurrence,” which can contain the start_date, end_date, and post.
In this case, you could have, for example, three EventOccurrence entries for a single post.
And so, in the search query, you would do it like this:
Search for EventOccurrences
start_datetime ≤ Current date/time
end_datetime ≥ Current date/time
And then you get the list of posts that would appear there.
1 Like
Oh my goodness it worked!! I had to use this page’s advice to make a list from the start input - end input, and I got it!
I should note: to make it work properly, the api workflow pulls the startdate input and changes the hours, minutes, and seconds to 0. Then the verticallist’s data source searches for eventoccurences containing the current date/time, changing hours, minutes, and seconds to 0 to match (otherwise I think the time of day the event is created would throw that off)
Anyway, thank you both for the quick and helpful responses!!!
1 Like