Skip to content

Refactor UploadManager.uploadNews Realm queries into VoicesRepository#11623

Closed
dogi wants to merge 1 commit intomasterfrom
refactor-upload-news-voices-repository-15545347176171038591
Closed

Refactor UploadManager.uploadNews Realm queries into VoicesRepository#11623
dogi wants to merge 1 commit intomasterfrom
refactor-upload-news-voices-repository-15545347176171038591

Conversation

@dogi
Copy link
Copy Markdown
Member

@dogi dogi commented Mar 2, 2026

This refactor extracts the raw Realm database queries previously located in UploadManager.uploadNews and moves them into the VoicesRepository layer. A new DTO, NewsUploadData, has been created to safely pass the necessary fields and the serialized JSON (via chatRepository) back to the UploadManager. Additionally, the database modifications required after a successful upload have been abstracted into VoicesRepository.markNewsUploaded(...). This aligns with the repository pattern and keeps database coupling out of the service layer.


PR created automatically by Jules for task 15545347176171038591 started by @dogi

…sitory

- Created `NewsUploadData` DTO to hold unmanaged news properties
- Added `getPendingNews(chatRepository)` and `markNewsUploaded(...)` to `VoicesRepository` and `VoicesRepositoryImpl`
- Updated `UploadManager.uploadNews` to use `VoicesRepository` instead of direct Realm operations
- Injected `VoicesRepository` into `UploadManager` via Dagger/Hilt (`ServiceModule`)

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@dogi dogi added the triage Further information is requested label Mar 2, 2026
@qltysh
Copy link
Copy Markdown

qltysh bot commented Mar 2, 2026

❌ 1 blocking issue (1 total)

Tool Category Rule Count
qlty Structure Function with many parameters (count = 12): provideUploadManager 1

uploadConfigs: org.ole.planet.myplanet.services.upload.UploadConfigs,
teamsRepository: Lazy<org.ole.planet.myplanet.repository.TeamsRepository>
teamsRepository: Lazy<org.ole.planet.myplanet.repository.TeamsRepository>,
voicesRepository: org.ole.planet.myplanet.repository.VoicesRepository
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function with many parameters (count = 12): provideUploadManager [qlty:function-parameters]

Copy link
Copy Markdown
Collaborator

@Okuro3499 Okuro3499 left a comment

Choose a reason for hiding this comment

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

1. Repository-to-repository coupling via parameter (VoicesRepository:40)
suspend fun getPendingNews(chatRepository: ChatRepository): List<NewsUploadData>
VoicesRepository is now accepting ChatRepository as a parameter of a repository interface method. This creates an explicit horizontal dependency between two domain repositories — a direct violation of layered architecture. Repositories should not depend on each other; they share the same layer and should both depend on lower-level services only.
Fix: inject ChatRepository into VoicesRepositoryImpl's constructor (it already has Hilt @Inject) and remove the parameter from the interface.

2. news.id!! force-unwrap crash (UploadManager.kt:674)
  voicesRepository.markNewsUploaded(
      news.id!!,   // ← throws NPE if id is null
      ...
  )
The old code used equalTo("id", news.id) which would simply find nothing if null. The new call crashes the process. NewsUploadData.id is typed String?, so this is a genuine regression.
Fix: skip the item (continue) or guard with ?: continue before calling markNewsUploaded.

@dogi dogi closed this Mar 3, 2026
@dogi dogi deleted the refactor-upload-news-voices-repository-15545347176171038591 branch March 18, 2026 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes requested close? triage Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants