AOSSIE-Org / AOSSIE-Org/PictoPy

Feat: Weekends category in memories section

Aberta
#1,213 5 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
283
Forks
679
Merge médio
7d 2h
PRs com merge (30d)
3

Descrição

### Describe the feature

### Description
Added a “Weekends” category in the Memories section to cluster all images that fall within a weekend.
### Current Problem

The Memories section groups photos by **location** and **date**, but there is no way to browse photos specifically from weekends. Users who take most of their photos on weekends (trips, hangouts, events) have no dedicated view to relive those moments as a cohesive group. The existing filter buttons **All**, **Location**, and **Date** do not surface weekend-specific clusters.

### Expected Feature

A new **"Weekends"** filter button in the Memories section that:

- Groups all photos by their ISO calendar week, producing one memory cluster per week that contains images.
- Displays each cluster as a **"Happy Weekends"** card showing the thumbnail of the first photo, the date range of that week's photos, and the total photo count.
- If a cluster spans a single day, shows only that date; otherwise shows **start date – end date**.
- Clicking a card opens a full detail view displaying all photos in that cluster, using the same `ImageCard` grid and `MediaView` full-screen viewer used by the rest of the Memories section.

---

## Implementation

### Backend — `generate_clusters_for_weekends()` in `memory_clustering.py`

A standalone function `generate_clusters_for_weekends()` was added at the bottom of `backend/app/utils/memory_clustering.py`:

1. Fetches all images from the database via `db_get_all_images()`.
2. Sorts images by `metadata.date_created` descending (most recent first).
3. Iterates over every image, parses its ISO date, and extracts the **ISO calendar year + week number** using `datetime.isocalendar()` , this forms a unique `week_key` (e.g. `"2025-W48"`).
4. Returns `list(weekend_memories.values())`, each element is:
```python
{
"mem_id": "",
"images": [{"id": ..., "path": ..., "thumbnailPath": ...}, ...],
"start_date": "YYYY-MM-DD", # earliest photo date in the ISO week
"end_date": "YYYY-MM-DD", # latest photo date in the ISO week
}
```
7. The `GET /api/memories/weekly-memories` endpoint in `routes/memories.py` calls this function and returns a `WeeklyMemoriesResponse` containing `weekly_memories`.

### Frontend

| Layer | Change |
|---|---|
| `apiEndpoints.ts` | Added `weeklyMemories: '/api/memories/weekly-memories'` to `memoriesEndpoints`. |
| `api-functions/memories.ts` | Added `WeeklyMemoryImage`, `WeeklyMemory`, `WeeklyMemoriesResponse` interfaces and `getWeeklyMemories()` which performs a `GET` to the endpoint and returns the typed response. |
| `hooks/useMemories.tsx` | Added `useWeeklyMemories()` Tanstack Query hook (5-min stale time). |
| `MemoriesPage.tsx` | Added **Weekends** filter button. When active, hides all other sections and renders a `WeekendMemoryCard` grid. Each card uses `thumbnailPath` via `convertFileSrc()` for a fast thumbnail. Clicking a card renders `WeekendMemoryDetail`, which loads the cluster's images into Redux (`setImages`) and renders `ImageCard` + `MediaView` — the same pattern used by `MemoryDetail` — enabling full-screen image browsing. |

***Note: ChatGPT was used to refine the statements above and to organize the structure of the issue.***

### Add ScreenShots

## Screenshots
### Before : No `Weekends` category.

Image

### After : With `Weekends` category

Image

Image

Image

### Record

- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.