Skip to content

Commit

Permalink
Improve closing time intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Nov 14, 2024
1 parent ba17959 commit 40738e6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
7 changes: 3 additions & 4 deletions backend/shared/src/supabase/search-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,9 @@ function getSearchContractWhereSQL(args: {
const filterSQL: FilterSQL = {
open: 'resolution_time IS NULL AND (close_time > NOW() or close_time is null)',
closed: 'close_time < NOW() AND resolution_time IS NULL',
// Include an extra day to capture markets that close on the first of the month. Add 7 hours to shift UTC time zone to PT.
'closing-this-month': `close_time > now() AND close_time < (date_trunc('month', now()) + interval '1 month' + interval '1 day' + interval '7 hours') AND resolution_time IS NULL`,
'closing-next-month': `close_time > ((date_trunc('month', now()) + interval '1 month') + interval '1 day' + interval '7 hours') AND close_time < (date_trunc('month', now()) + interval '2 month' + interval '1 day' + interval '7 hours') AND resolution_time IS NULL`,
closing: `close_time > now() AND close_time < now() + interval '1 month' + interval '1 day' + interval '7 hours' AND resolution_time IS NULL`,
'closing-week': `close_time > now() AND close_time < (now() + interval '7 days' + interval '7 hours') AND resolution_time IS NULL`,
'closing-month': `close_time > now() AND close_time < (now() + interval '30 days' + interval '7 hours') AND resolution_time IS NULL`,
'closing-90-days': `close_time > now() AND close_time < (now() + interval '90 days' + interval '7 hours') AND resolution_time IS NULL`,
resolved: 'resolution_time IS NOT NULL',
all: '',
}
Expand Down
6 changes: 3 additions & 3 deletions common/src/api/market-search-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const searchProps = z
filter: z
.union([
z.literal('open'),
z.literal('closing-this-month'),
z.literal('closing-next-month'),
z.literal('closing'),
z.literal('closing-90-days'),
z.literal('closing-week'),
z.literal('closing-month'),
z.literal('closed'),
z.literal('resolved'),
z.literal('all'),
Expand Down
6 changes: 3 additions & 3 deletions web/components/search/contract-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,16 @@ export function ContractFilters(props: {
key="closing"
className={clsx(
'flex h-6 cursor-pointer select-none flex-row items-center whitespace-nowrap rounded-full px-2 text-sm outline-none transition-colors',
filter == 'closing'
filter == 'closing-month'
? 'hover:bg-primary-600 focus-visible:bg-primary-600 bg-primary-500 text-white'
: 'bg-ink-200 text-ink-600 dark:bg-ink-300',
className
)}
onClick={() => {
if (filter === 'closing') {
if (filter === 'closing-month') {
selectFilter('open')
} else {
selectFilter('closing')
selectFilter('closing-month')
}
}}
>
Expand Down
6 changes: 3 additions & 3 deletions web/components/supabase-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ export type Sort = (typeof SORTS)[number]['value']
export const FILTERS = [
{ label: 'Any status', value: 'all' },
{ label: 'Open', value: 'open' },
{ label: 'Closing this month', value: 'closing-this-month' },
{ label: 'Closing next month', value: 'closing-next-month' },
{ label: 'Closing in 30 days', value: 'closing' },
{ label: 'Closing in 7 days', value: 'closing-week' },
{ label: 'Closing in 30 days', value: 'closing-month' },
{ label: 'Closing in 90 days', value: 'closing-90-days' },
{ label: 'Closed', value: 'closed' },
{ label: 'Resolved', value: 'resolved' },
] as const
Expand Down

0 comments on commit 40738e6

Please sign in to comment.