Skip to content

default sort by closest to user #466

Open
@jacobvenable

Description

@jacobvenable

related to #465

Description

When retrieving resources by category or subcategory, the client app sorts the results by what is open.

const resources = sortByOpen(

We should add another sorting step that sorts the resources to display those closest to the user first. This could either be done client-side (with another sorting function) or we could update the api to do both of these sorting options server side.

If we want to move this logic to the server, we will need to make a new endpoint (something like /api/v2/resources) where the client can send in a bunch of query params and get the specific results they are looking for.

interface ResourcesV2Params {
  category?: string;
  subcategory?: string;
  coordinates?: string;
  /** we may not need this yet but if we ever expand outside of Boulder this could be nice */
  localtime?: string;
  /** optional - but one day soon we may need to paginate these results */
  page?: number;
}

Checklist

  • Decide if this logic should live client-side or server-side.
  • when retrieving resources by a category and sub-category, and the user provides their coordinates (OR we apply the sorting client-side and leave the API as it is), the list of resources provided is sorted in the following order by default:
  1. resources that are open sorted by those closest to the user
  2. resources that are closed sorted by those closest to the user
  • when retrieving resources by a category and sub-category, and the user does not provide their coordinates, the list of resources is not sorted by proximity to the user (OR we just leave the API as it is)

Tech Notes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions