Skip to content

show all shelters under map boundries (SDB-103)#2004

Open
Davit-BetterAngels wants to merge 1 commit intomainfrom
SDB-103/pins-locations
Open

show all shelters under map boundries (SDB-103)#2004
Davit-BetterAngels wants to merge 1 commit intomainfrom
SDB-103/pins-locations

Conversation

@Davit-BetterAngels
Copy link
Copy Markdown
Contributor

@Davit-BetterAngels Davit-BetterAngels commented Apr 2, 2026

SDB-103

Summary by Sourcery

Simplify shelter card imagery and switch shelter search to load all shelters within bounds in a single query instead of using infinite scrolling.

Bug Fixes:

  • Ensure all shelters within the specified map boundaries are fetched by requesting a large, fixed-size result set.

Enhancements:

  • Simplify ShelterCardHero to display only the primary hero image or a placeholder instead of handling multiple photo layouts.
  • Remove use of infinite-scroll querying in shelter search in favor of a standard GraphQL query and update the list component configuration accordingly.
  • Streamline shelter GraphQL schema usage by dropping unused exterior and interior photo fields from the shelter list query.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 2, 2026

Reviewer's Guide

Refactors shelter listing to fetch and display all shelters within map boundaries in a single paginated query, simplifies image handling on shelter cards to use only the hero image, and removes now-unused multi-photo support and infinite scroll pagination wiring.

Sequence diagram for fetching and displaying all shelters within map boundaries

sequenceDiagram
  actor User
  participant MapView
  participant SheltersDisplay
  participant ApolloClient
  participant GraphQLAPI

  User->>MapView: Pan or zoom map
  MapView->>SheltersDisplay: onBoundsChange(newBounds)
  SheltersDisplay->>SheltersDisplay: build queryVariables from bounds
  SheltersDisplay->>ApolloClient: useQuery(ViewShelters, variables + pagination{limit:5000,offset:0})
  ApolloClient->>GraphQLAPI: ViewShelters(queryVariables, pagination)
  GraphQLAPI-->>ApolloClient: shelters{results, totalCount}
  ApolloClient-->>SheltersDisplay: data, loading=false, error
  SheltersDisplay->>SheltersDisplay: shelters = data.shelters.results
  SheltersDisplay->>SheltersDisplay: useEffect setSheltersData(shelters)
  SheltersDisplay->>InfiniteList: render with data=shelters, hasMore=false
  InfiniteList->>User: Display all shelters in current bounds (no infinite scroll)
Loading

Class diagram for updated shelter card structures and shelters display

classDiagram
  class TShelter {
    string id
    string name
    string heroImage
    number distanceInMiles
    TShelterLocation location
    %% removed: exteriorPhotos
    %% removed: interiorPhotos
  }

  class TShelterLocation {
    number latitude
    number longitude
    string city
    string state
  }

  class ShelterCard {
    +ShelterCard(props)
    -string id
    -string name
    -string heroImage
    -number distanceInMiles
    -TShelterLocation location
    -function onNavigate()
  }

  class ShelterCardHero {
    +ShelterCardHero(props)
    -string shelterName
    -string imageUrl
    -string className
    -string[] imageCss
  }

  class SheltersDisplay {
    +SheltersDisplay(props)
    -TShelter[] shelters
    -number total
    -function buildQueryVariables()
    -function renderListHeader(visible, total)
  }

  class InfiniteList~TShelter~ {
    +render()
    -TShelter[] data
    -number totalItems
    -boolean loading
    -boolean hasMore
    -Error error
  }

  TShelterLocation --> TShelter : location
  TShelter --> ShelterCard : shelter
  ShelterCardHero --> ShelterCard : used for hero image
  TShelter --> SheltersDisplay : sheltersData
  SheltersDisplay --> InfiniteList~TShelter~ : passes data and total

  class ViewSheltersQuery {
    TShelterConnection shelters
  }

  class TShelterConnection {
    TShelter[] results
    number totalCount
  }

  ViewSheltersQuery --> TShelterConnection : shelters
  TShelterConnection --> TShelter : results

  class ApolloUseQuery {
    +useQuery(document, variables)
  }

  SheltersDisplay --> ApolloUseQuery : ViewSheltersDocument
Loading

File-Level Changes

Change Details Files
Replace infinite-scroll shelters query with a single, large-page GraphQL query and wire it into the list and shared shelters state.
  • Swapped useInfiniteScrollQuery usage in SheltersDisplay for a standard useQuery on ViewSheltersDocument with explicit pagination variables (limit 5000, offset 0).
  • Derived shelters and total from the new query response using useMemo, with a skip condition when queryVariables are not available.
  • Updated the shared sheltersData state via useEffect to use the new shelters array dependency.
  • Adjusted InfiniteList props to use shelters as data, the new total count, removed loadMore/loadingMore, and hard-coded hasMore to false since all items are loaded at once.
libs/react/shelter/src/lib/components/ShelterSearch/SheltersDisplay.tsx
Simplify shelter card imagery to only use the hero image and remove multi-photo carousel/grid behavior and related data fields.
  • Removed photos prop from ShelterCardHero and associated logic for generating image URL arrays from photos and imageUrl.
  • Deleted conditional logic that rendered different layouts for 1, 2, or many photos (grid and horizontal scroll thumbnails), leaving a single hero image rendering path with a placeholder fallback when imageUrl is missing.
  • Simplified TShelterCard and TShelter by removing exteriorPhotos and interiorPhotos fields and the logic that merged them into a photos array in ShelterCard.
  • Updated ShelterCard usage of ShelterCardHero to pass only heroImage as imageUrl and shelterName.
  • Removed exteriorPhotos and interiorPhotos selections from the ViewShelters GraphQL query and regenerated the TypeScript artifacts accordingly.
libs/react/shelter/src/lib/components/ShelterCard/ShelterCardHero.tsx
libs/react/shelter/src/lib/components/ShelterCard/ShelterCard.tsx
libs/react/shelter/src/lib/pages/shelters/shelters.graphql
libs/react/shelter/src/lib/pages/shelters/__generated__/shelters.generated.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The fixed pagination: { limit: 5000, offset: 0 } is a fairly arbitrary magic number and could lead to heavy responses for dense areas; consider making this configurable (or capped by the API) and documenting the expected upper bound of shelters per bounds.
  • Since InfiniteList is now always passed hasMore={false} and no loadMore handler, it might be worth simplifying to a non-infinite list component or ensuring InfiniteList gracefully handles this mode to avoid unnecessary complexity or assumptions about infinite scrolling.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The fixed `pagination: { limit: 5000, offset: 0 }` is a fairly arbitrary magic number and could lead to heavy responses for dense areas; consider making this configurable (or capped by the API) and documenting the expected upper bound of shelters per bounds.
- Since `InfiniteList` is now always passed `hasMore={false}` and no `loadMore` handler, it might be worth simplifying to a non-infinite list component or ensuring `InfiniteList` gracefully handles this mode to avoid unnecessary complexity or assumptions about infinite scrolling.

## Individual Comments

### Comment 1
<location path="libs/react/shelter/src/lib/components/ShelterSearch/SheltersDisplay.tsx" line_range="83-89" />
<code_context>
-      variables: queryVariables,
-      pageSize: 25,
-    });
+  const { data, loading, error } = useQuery<
+    ViewSheltersQuery,
+    ViewSheltersQueryVariables
+  >(ViewSheltersDocument, {
+    variables: {
+      ...queryVariables,
+      pagination: { limit: 5000, offset: 0 },
+    },
+    skip: !queryVariables,
</code_context>
<issue_to_address>
**issue (bug_risk):** Hard-coded pagination limit of 5000 can truncate results and cause scalability issues.

This change introduces two issues:

1. When `totalCount` > 5000, results after the first 5000 are silently dropped because `hasMore` is effectively disabled and there’s no way to request additional pages.
2. Loading up to 5000 shelters in one request is expensive (bandwidth, memory, render time), particularly on mobile.

Instead of a single large page with `hasMore={false}`, consider either paginating properly (e.g., incrementing `offset` and wiring `hasMore` to `total > shelters.length`) or using a smaller, justified limit and clearly indicating any cap in the UI.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +83 to +89
const { data, loading, error } = useQuery<
ViewSheltersQuery,
ViewSheltersQueryVariables
>(ViewSheltersDocument, {
variables: {
...queryVariables,
pagination: { limit: 5000, offset: 0 },
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Hard-coded pagination limit of 5000 can truncate results and cause scalability issues.

This change introduces two issues:

  1. When totalCount > 5000, results after the first 5000 are silently dropped because hasMore is effectively disabled and there’s no way to request additional pages.
  2. Loading up to 5000 shelters in one request is expensive (bandwidth, memory, render time), particularly on mobile.

Instead of a single large page with hasMore={false}, consider either paginating properly (e.g., incrementing offset and wiring hasMore to total > shelters.length) or using a smaller, justified limit and clearly indicating any cap in the UI.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

🔍 [shelter-web] Preview available at: https://shelter.dev.betterangels.la/branches/SDB-103-pins-locations

Last updated: 2026-04-02T09:08:21.604Z

@kimchoi-jjiggae
Copy link
Copy Markdown

image When I first open the link there are more listed than displayed (110 listed, but fewer on the map)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants