AOSSIE-Org / AOSSIE-Org/PictoPy
BUG: Incorrect tagging on memory cards for 'Dates' & 'Location'
- Langage dominant
- Python
- Étoiles
- 283
- Forks
- 679
- Merge moyen
- 7 j 2 h
- PR mergées (30 j)
- 3
Description
### Is there an existing issue for this?
- [x] 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.
```python
# 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
```
```python
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

### After Screenshots:
- Displaying correct Tagging and Sorting Values


### Record
- [x] I agree to follow this project's Code of Conduct
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.