Skip to content

Conversation

Copy link

Copilot AI commented Nov 10, 2025

Hardcoded string keys for Firestore fields in ProductServiceImpl create maintenance risk and enable typos. Refactored to use compile-time constants.

Changes

  • Added field name constants to model classes

    • FoodItem.companion object defines constants for all Firestore fields (id, barcode, userId, name, expiryTimestamp, quantity, unit, storageLocation, category, status, householdId, picture)
    • Activity.companion object defines FIELD_ID constant
  • Updated ProductServiceImpl to use constants

    • Replaced hardcoded strings in addProduct(), updateProduct(), and logActivity() methods
    • Applied to map initialization, whereEqualTo queries, and Firestore update operations

Example

// Before
val foodItemData = mutableMapOf<String, Any>(
    "userId" to user.id,
    "name" to productName,
    "expiryTimestamp" to expiryTimestamp
)

// After
val foodItemData = mutableMapOf<String, Any>(
    FoodItem.FIELD_USER_ID to user.id,
    FoodItem.FIELD_NAME to productName,
    FoodItem.FIELD_EXPIRY_TIMESTAMP to expiryTimestamp
)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: maxschwinghammer <111356450+maxschwinghammer@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 10, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/agents/gradle-instrumentation-agent-8.13.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.13 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update to address feedback on barcode usage Replace hardcoded Firestore field names with constants Nov 10, 2025
Copilot finished work on behalf of maxschwinghammer November 10, 2025 08:11
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