Skip to content
Myr

groups.ts

This file

Path

apps/web/src/features/explore/groups.ts

29 lines · 1004 bytes · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 1–29why, one step back
1import type { ProjectListing } from "@repo/protocol/domain/front-page";
2import { Array as Arr, DateTime, Order } from "effect";34export interface ExploreGroups {5 /** Projects with an open ask, so a reader looking for work sees them first. */6 readonly taking: readonly ProjectListing[];7 readonly rest: readonly ProjectListing[];8}910const NEVER = Number.NEGATIVE_INFINITY;1112// The latest landing first, a project not yet landed last, a tie by name.13const byLatestLanding = Order.combine(14 Order.mapInput(Order.flip(Order.Number), ({ landedAt }: ProjectListing) =>15 landedAt === undefined ? NEVER : DateTime.toEpochMillis(landedAt)16 ),17 Order.mapInput(Order.String, ({ project }: ProjectListing) => project)18);1920export const exploreGroups = (21 projects: readonly ProjectListing[]22): ExploreGroups => {23 const sorted = Arr.sort(projects, byLatestLanding);2425 return {26 rest: sorted.filter(({ openAsks }) => openAsks === 0),27 taking: sorted.filter(({ openAsks }) => openAsks > 0),28 };29};