Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ class ProductServiceImpl
else -> null
}

val cleanedBarcode = barcode?.takeIf { it.isNotBlank() }

val foodItem =
FoodItem(
barcode = barcode,
barcode = cleanedBarcode,
userId = user.id,
householdId = householdId,
name = productName,
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

The FoodItem object is created but never used after line 119 switches to using foodItemData. This creates unnecessary object instantiation and potential confusion about which data structure is actually persisted.

Copilot uses AI. Check for mistakes.
Expand All @@ -96,9 +98,25 @@ class ProductServiceImpl
picture = picture,
)
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

The FoodItem object is created but never used after line 119 switches to using foodItemData. This creates unnecessary object instantiation and potential confusion about which data structure is actually persisted.

Copilot uses AI. Check for mistakes.

val foodItemData =
mutableMapOf<String, Any>(
"userId" to user.id,
"name" to productName,
"expiryTimestamp" to expiryTimestamp,
"quantity" to quantity,
"unit" to unit,
"storageLocation" to storageLocation,
"category" to category,
"status" to FoodStatus.ACTIVE,
).apply {
cleanedBarcode?.let { this["barcode"] = it }
householdId?.let { this["householdId"] = it }
picture?.let { this["picture"] = it }
}
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

The hardcoded string keys in the map create a maintenance risk and potential for typos. Consider using property names from the FoodItem class or defining constants for these field names to ensure consistency.

Copilot uses AI. Check for mistakes.

firestore
.collection("foodItems")
.add(foodItem)
.add(foodItemData)
.addOnSuccessListener { documentReference ->
firestore
.collection("foodItems")
Expand Down