fix(list): restore added-by attribution with display name fallback
All checks were successful
Build & Deploy Costco Grocery List / build (push) Successful in 1m7s
Build & Deploy Costco Grocery List / verify-images (push) Successful in 3s
Build & Deploy Costco Grocery List / deploy (push) Successful in 12s
Build & Deploy Costco Grocery List / notify (push) Successful in 1s

This commit is contained in:
Nico 2026-02-21 00:07:22 -08:00
parent 3dd58f51e8
commit ee94853084
2 changed files with 22 additions and 17 deletions

View File

@ -18,14 +18,14 @@ exports.getHouseholdStoreList = async (householdId, storeId, includeHistory = tr
hl.custom_image_mime_type as image_mime_type, hl.custom_image_mime_type as image_mime_type,
${includeHistory ? ` ${includeHistory ? `
( (
SELECT ARRAY_AGG(DISTINCT u.name) SELECT ARRAY_AGG(added_by_labels.user_label ORDER BY added_by_labels.user_label)
FROM ( FROM (
SELECT DISTINCT hlh.added_by SELECT DISTINCT
COALESCE(NULLIF(TRIM(u.display_name), ''), NULLIF(TRIM(u.name), ''), u.username) AS user_label
FROM household_list_history hlh FROM household_list_history hlh
JOIN users u ON hlh.added_by = u.id
WHERE hlh.household_list_id = hl.id WHERE hlh.household_list_id = hl.id
ORDER BY hlh.added_by ) added_by_labels
) hlh
JOIN users u ON hlh.added_by = u.id
) as added_by_users, ) as added_by_users,
` : 'NULL as added_by_users,'} ` : 'NULL as added_by_users,'}
hl.modified_on as last_added_on, hl.modified_on as last_added_on,
@ -74,14 +74,14 @@ exports.getItemByName = async (householdId, storeId, itemName) => {
ENCODE(hl.custom_image, 'base64') as item_image, ENCODE(hl.custom_image, 'base64') as item_image,
hl.custom_image_mime_type as image_mime_type, hl.custom_image_mime_type as image_mime_type,
( (
SELECT ARRAY_AGG(DISTINCT u.name) SELECT ARRAY_AGG(added_by_labels.user_label ORDER BY added_by_labels.user_label)
FROM ( FROM (
SELECT DISTINCT hlh.added_by SELECT DISTINCT
COALESCE(NULLIF(TRIM(u.display_name), ''), NULLIF(TRIM(u.name), ''), u.username) AS user_label
FROM household_list_history hlh FROM household_list_history hlh
JOIN users u ON hlh.added_by = u.id
WHERE hlh.household_list_id = hl.id WHERE hlh.household_list_id = hl.id
ORDER BY hlh.added_by ) added_by_labels
) hlh
JOIN users u ON hlh.added_by = u.id
) as added_by_users, ) as added_by_users,
hl.modified_on as last_added_on, hl.modified_on as last_added_on,
hic.item_type, hic.item_type,
@ -289,14 +289,14 @@ exports.getRecentlyBoughtItems = async (householdId, storeId) => {
ENCODE(hl.custom_image, 'base64') as item_image, ENCODE(hl.custom_image, 'base64') as item_image,
hl.custom_image_mime_type as image_mime_type, hl.custom_image_mime_type as image_mime_type,
( (
SELECT ARRAY_AGG(DISTINCT u.name) SELECT ARRAY_AGG(added_by_labels.user_label ORDER BY added_by_labels.user_label)
FROM ( FROM (
SELECT DISTINCT hlh.added_by SELECT DISTINCT
COALESCE(NULLIF(TRIM(u.display_name), ''), NULLIF(TRIM(u.name), ''), u.username) AS user_label
FROM household_list_history hlh FROM household_list_history hlh
JOIN users u ON hlh.added_by = u.id
WHERE hlh.household_list_id = hl.id WHERE hlh.household_list_id = hl.id
ORDER BY hlh.added_by ) added_by_labels
) hlh
JOIN users u ON hlh.added_by = u.id
) as added_by_users, ) as added_by_users,
hl.modified_on as last_added_on hl.modified_on as last_added_on
FROM household_lists hl FROM household_lists hl

View File

@ -97,6 +97,11 @@ function GroceryListItem({ item, onClick, onImageAdded, onLongPress, allItems =
const imageUrl = item.item_image && item.image_mime_type const imageUrl = item.item_image && item.image_mime_type
? `data:${item.image_mime_type};base64,${item.item_image}` ? `data:${item.image_mime_type};base64,${item.item_image}`
: null; : null;
const addedByUsers = Array.isArray(item.added_by_users)
? item.added_by_users.filter(
(name) => typeof name === "string" && name.trim().length > 0
)
: [];
const getTimeAgo = (dateString) => { const getTimeAgo = (dateString) => {
if (!dateString) return null; if (!dateString) return null;
@ -146,10 +151,10 @@ function GroceryListItem({ item, onClick, onImageAdded, onLongPress, allItems =
<div className="glist-item-header"> <div className="glist-item-header">
<span className="glist-item-name">{item.item_name}</span> <span className="glist-item-name">{item.item_name}</span>
</div> </div>
{item.added_by_users && item.added_by_users.length > 0 && ( {addedByUsers.length > 0 && (
<div className="glist-item-users"> <div className="glist-item-users">
{item.last_added_on && `${getTimeAgo(item.last_added_on)} -- `} {item.last_added_on && `${getTimeAgo(item.last_added_on)} -- `}
{item.added_by_users.join(" • ")} {addedByUsers.join(" | ")}
</div> </div>
)} )}
</div> </div>