AOSSIE-Org / AOSSIE-Org/PictoPy

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

Abierto
#1,178 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
283
Forks
679
Merge medio
7 d 2 h
PR fusionados (30 d)
3

Descripción

### 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

![Image](https://github.com/user-attachments/assets/1128f776-d7ba-425c-98bc-bf75ce216b7b)

### After Screenshots:
- Displaying correct Tagging and Sorting Values
![Image](https://github.com/user-attachments/assets/47643bac-8170-4513-b70a-1c9b236f5285)

![Image](https://github.com/user-attachments/assets/55da7eaf-543a-41ba-8f91-47747685370a)

### Record

- [x] I agree to follow this project's Code of Conduct

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.