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
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:
parent
3dd58f51e8
commit
ee94853084
@ -18,14 +18,14 @@ exports.getHouseholdStoreList = async (householdId, storeId, includeHistory = tr
|
||||
hl.custom_image_mime_type as image_mime_type,
|
||||
${includeHistory ? `
|
||||
(
|
||||
SELECT ARRAY_AGG(DISTINCT u.name)
|
||||
SELECT ARRAY_AGG(added_by_labels.user_label ORDER BY added_by_labels.user_label)
|
||||
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
|
||||
JOIN users u ON hlh.added_by = u.id
|
||||
WHERE hlh.household_list_id = hl.id
|
||||
ORDER BY hlh.added_by
|
||||
) hlh
|
||||
JOIN users u ON hlh.added_by = u.id
|
||||
) added_by_labels
|
||||
) as added_by_users,
|
||||
` : 'NULL as added_by_users,'}
|
||||
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,
|
||||
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 (
|
||||
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
|
||||
JOIN users u ON hlh.added_by = u.id
|
||||
WHERE hlh.household_list_id = hl.id
|
||||
ORDER BY hlh.added_by
|
||||
) hlh
|
||||
JOIN users u ON hlh.added_by = u.id
|
||||
) added_by_labels
|
||||
) as added_by_users,
|
||||
hl.modified_on as last_added_on,
|
||||
hic.item_type,
|
||||
@ -289,14 +289,14 @@ exports.getRecentlyBoughtItems = async (householdId, storeId) => {
|
||||
ENCODE(hl.custom_image, 'base64') as item_image,
|
||||
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 (
|
||||
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
|
||||
JOIN users u ON hlh.added_by = u.id
|
||||
WHERE hlh.household_list_id = hl.id
|
||||
ORDER BY hlh.added_by
|
||||
) hlh
|
||||
JOIN users u ON hlh.added_by = u.id
|
||||
) added_by_labels
|
||||
) as added_by_users,
|
||||
hl.modified_on as last_added_on
|
||||
FROM household_lists hl
|
||||
|
||||
@ -97,6 +97,11 @@ function GroceryListItem({ item, onClick, onImageAdded, onLongPress, allItems =
|
||||
const imageUrl = item.item_image && item.image_mime_type
|
||||
? `data:${item.image_mime_type};base64,${item.item_image}`
|
||||
: 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) => {
|
||||
if (!dateString) return null;
|
||||
@ -146,10 +151,10 @@ function GroceryListItem({ item, onClick, onImageAdded, onLongPress, allItems =
|
||||
<div className="glist-item-header">
|
||||
<span className="glist-item-name">{item.item_name}</span>
|
||||
</div>
|
||||
{item.added_by_users && item.added_by_users.length > 0 && (
|
||||
{addedByUsers.length > 0 && (
|
||||
<div className="glist-item-users">
|
||||
{item.last_added_on && `${getTimeAgo(item.last_added_on)} -- `}
|
||||
{item.added_by_users.join(" • ")}
|
||||
{addedByUsers.join(" | ")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user