Skip to content

Refactor my-participating-studies-section.tsx: Implement backend API for participating studies #372

@coderabbitai

Description

@coderabbitai

Context

This component is currently a temporary implementation that needs refactoring once a proper backend API becomes available.

Related PR: #370
Comment discussion: #370 (comment)
File: src/components/section/my-participating-studies-section.tsx

Current Implementation

The component currently:

  • Fetches all studies via useGetStudies (paginated, but fetching 100 items)
  • Fetches user's participating study list via useMemberStudyListQuery
  • Creates a Set of participating study IDs client-side
  • Filters the complete study list against this ID set on the client
  • Limits to 3 studies for display

Problem

  • Performance concern: As the number of studies grows, fetching and filtering all studies client-side becomes inefficient
  • Data type mismatch: The participating studies list and full studies list have different data structures, requiring this workaround
  • Network overhead: Unnecessary data transfer for studies the user isn't participating in

Proposed Solution

Implement one of these backend API improvements:

Option 1: Batch fetch by IDs

GET /api/v1/group-studies/by-ids?ids=1,2,3&classification=GROUP_STUDY

Returns full study details for the specified IDs only.

Option 2: Enhance existing endpoint

Modify getMemberStudyList to return all information needed for StudyCard rendering, eliminating the need for a second API call.

Next Steps

  • Backend team implements appropriate API endpoint
  • Refactor component to use new endpoint
  • Remove or optimize client-side filtering
  • Consider whether this feature should remain permanent or be removed

Notes

  • This feature may be removed in the future depending on product decisions
  • Component should be treated as temporary until refactoring is completed
  • Requested by @seong-jin-jo

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions