Skip to content

BUG: Incorrect tagging on memory cards for 'Dates' & 'Location' #1178

@codex-yv

Description

@codex-yv

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Description

All memory cards in the Memory Section are displaying the same tag, ‘Location’, even when the latitude and longitude values are null or the location name is empty. As a result, the sorting buttons do not produce accurate results.

Steps to reproduce

(Add some images I.e. 200)

  • Launch PictoPy on your desktop.
  • Click Memories Button on sidebar
  • Observe that all memory cards display the ‘Location’ tag, even when no location data is available.
  • Notice that the sorting buttons do not show appropriate values or results.

Expected Behaviour

  • Memories that have a location (i.e., a location_name) should display the Location tag.
  • Memories without a location should display the Date tag instead.
  • The sorting buttons should show appropriate values and produce results accordingly.

Implementation

  • When memory type is not a Location in _create_simple_memory in memor_clustering.py then location_name = None and it's category will be 'Date' and added total_location to get total memories which has location.
# function to count total memories which has location
# this can also be done in tsx.
def find_total_location_memories(data:list) -> int:
    tlm = 0 # total location memories
    for memory in data:
        if memory["location_name"] != None:
            tlm +=1
    return tlm 
return {
            "data": {
                "memory_count": len(memories),
                "image_count": len(images),
                "memories": memories,
            },
            "total_location":tlm, #new key
            "success": True,
            "message": f"{len(memories)} memories ({location_count} location, {date_count} date)",
        }

The above part can be done directly in frontend section

  • Updated locationCount Source: In MemoriesPage.tsx, the locationCount (displayed on the "Location" filter button) is now primarily taken from the total_location field returned by the backend's /api/memories/generate endpoint. If the data is not yet available, it falls back to a local calculation.
  • Location Tag Visibility: In MemoryCard.tsx, the "Location" badge is now displayed only when the location_name is not null. I updated the isDateBased logic to check for the absence of location_name instead of geographic coordinates.
  • Refined Filtering: In MemoriesPage.tsx, the filtering logic for the Location and Date buttons has been updated to use the location_name field. Clicking "Location" now correctly displays only memory cards where location_name is not null, ensuring consistent behavior between the counts and the displayed cards.

Screenshots

Before Screenshots:

  • Displaying location tag even if there is no location available for this image

Image

After Screenshots:

  • Displaying correct Tagging and Sorting Values
    Image

Image

Record

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions