Skip to content

Conversation

@gpunto
Copy link
Contributor

@gpunto gpunto commented Oct 31, 2025

Goal

AND-854

aggregated_activities in a feed are also paginated. They already come in the response whenever we load new pages, so we should just take those and merge them with the local ones.

Implementation

I had to changeGetOrCreateInfo to use PaginationData directly instead of the PaginationResult wrapper, because the latter only allows for one list of paginated items, while here the pagination data refers to both activities and aggregatedActivities.

Testing

It's not trivial because you need a feed where there are enough aggregated activities to trigger pagination.

Checklist

  • Issue linked (if any)
  • Tests/docs updated
  • I have signed the Stream CLA (required for external contributors)

@gpunto gpunto requested a review from Copilot October 31, 2025 11:23
@gpunto gpunto added the pr:bug Bug fix label Oct 31, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2025

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the GetOrCreateInfo data class to flatten its structure by replacing the nested PaginationResult<ActivityData> with separate pagination and activities fields, and reorders the aggregatedActivities field for better logical grouping. It also introduces a new upsertAll utility function for batch upsert operations and improves test readability by using Kotlin's backtick test naming convention.

  • Refactors GetOrCreateInfo data class to flatten the activities structure
  • Introduces upsertAll utility function for efficient batch upsert operations
  • Updates test file to use descriptive Kotlin backtick test names and improve test assertions

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/utils/List.kt Adds new upsertAll function for batch upsert operations
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/repository/FeedsRepository.kt Refactors GetOrCreateInfo to use flat structure with separate pagination and activities fields
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/repository/FeedsRepositoryImpl.kt Updates implementation to construct GetOrCreateInfo with new structure
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/FeedStateImpl.kt Updates to use flattened GetOrCreateInfo structure and adds aggregated activities merging
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/FeedImpl.kt Updates onQueryMoreActivities call to pass separate parameters instead of nested result
stream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/utils/ListUpsertTest.kt Refactors tests with backtick names and adds test coverage for upsertAll function
stream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/state/FeedStateImplTest.kt Updates test to verify aggregated activities merging behavior
stream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/state/FeedImplTest.kt Updates test data construction to match new GetOrCreateInfo structure
stream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/repository/FeedsRepositoryImplTest.kt Updates test data construction to match new GetOrCreateInfo structure
Comments suppressed due to low confidence (1)

stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/utils/List.kt:50

  • The upsert function restricts the idSelector to return String, while the new upsertAll function uses a generic type R for the key. This inconsistency creates an API design issue where upsert is less flexible. Consider making upsert generic as well: internal fun <T, R> List<T>.upsert(element: T, idSelector: (T) -> R): List<T> to maintain consistency and flexibility across the API.
internal fun <T> List<T>.upsert(element: T, idSelector: (T) -> String): List<T> {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-feeds-android-client 2.35 MB 2.35 MB 0.00 MB 🟢

@gpunto gpunto force-pushed the and-854/paginate-aggregated-activities branch from b255b52 to 2fed45b Compare October 31, 2025 14:25
@gpunto gpunto marked this pull request as ready for review October 31, 2025 14:26
@sonarqubecloud
Copy link

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

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants