Commit Graph

164 Commits

Author SHA1 Message Date
Claudio Ortolina 319bb2e6eb Update esbuild from 0.26.0 to 0.27.0 2025-11-09 20:54:21 +00:00
Claudio Ortolina 80058eeb61 Update esbuild from 0.25.12 to 0.26.0 2025-11-09 09:50:07 +00:00
Claudio Ortolina 4a5ed2de1a Enable artists maintenance tasks 2025-11-07 17:14:45 +00:00
Claudio Ortolina 713d184b0d Prune dangling assets every day at 2am
Running this before regular vacuum so that vacuum can reclaim space
2025-11-07 12:17:46 +00:00
Claudio Ortolina bff1759da5 Update tailwind from 4.1.16 to 4.1.17 2025-11-06 19:45:23 +00:00
Claudio Ortolina 11acec56b2 Remove lotus
Unstable - and it messes with the repo connection, creating other
errors.
2025-11-03 17:29:37 +00:00
Claudio Ortolina 4a555fe01c Update esbuild from 0.25.11 to 0.25.12 2025-11-02 09:27:21 +00:00
Claudio Ortolina af8ca54d3e Run Repo vacuum via Oban scheduled job
This way if there's any resource contention to obtain a db connection,
Oban can manage retries.
2025-10-25 10:21:21 +01:00
Claudio Ortolina 7f6b1497ab Update tailwind from 4.1.15 to 4.1.16 2025-10-23 13:37:20 +01:00
Claudio Ortolina a30e1b32d7 Mount data analysis via Lotus packages 2025-10-22 16:33:07 +01:00
Claudio Ortolina 9bb3b689af Update tailwind from 4.1.14 to 4.1.15 2025-10-20 17:12:24 +01:00
Claudio Ortolina 47a33542b9 Update esbuild from 0.25.10 to 0.25.11 2025-10-15 09:57:43 +01:00
Claudio Ortolina 14934b25d9 Load the sqlite-vec extension 2025-10-11 21:47:02 +02:00
Claudio Ortolina 57dfd3d33d Remove ErrorTracker
Doesn't work with recent LiveView releases, and seems to be maintained
very slowly despite incoming PRs to fix the issues.
2025-10-03 10:15:23 +03:00
Claudio Ortolina a31892709e SENTRY_DSN is read automatically by the library 2025-10-03 07:48:37 +03:00
Claudio Ortolina 30c0af475d Update tailwind from 4.1.13 to 4.1.14 2025-10-01 21:08:13 +03:00
Claudio Ortolina 4c33d3f0aa Enable Sentry 2025-10-01 13:48:30 +03:00
Claudio Ortolina ee6cfaef79 Refresh Last.fm Feed every 5 minutes 2025-09-28 07:48:28 +03:00
Claudio Ortolina a3f2c75f69 Remove dns_cluster 2025-09-20 12:56:05 +03:00
Claudio Ortolina a1b5842148 Prune asset cache every 12 hours 2025-09-20 08:17:16 +03:00
Claudio Ortolina 9a6df80eca Update esbuild from 0.25.9 to 0.25.10 2025-09-18 10:23:39 +03:00
Claudio Ortolina 1f44e0ab9d Resolve host from Coolify's definition 2025-09-12 18:26:13 +03:00
Claudio Ortolina 21783f5dbf Resolve timezone from user browser 2025-09-11 22:14:15 +03:00
Claudio Ortolina c67fd27ea1 Fix timezone definition and handling across app 2025-09-11 16:17:20 +03:00
Claudio Ortolina a989418125 Update tailwind from 4.1.12 to 4.1.13 2025-09-05 10:30:26 +03:00
Claudio Ortolina 3519326c1a Experiment with improving sqlite performance
- Auto vacuum to write more often to the db file. Should prevent backing
  up the database and finding missing data.
- Create temporary indexes in memory - should be faster than disk
2025-09-02 14:30:27 +03:00
Claudio Ortolina def57284b1 Increase specs of production database 2025-08-24 20:43:31 +03:00
Claudio Ortolina 967c68a24d Show errors on connection 2025-08-24 11:25:40 +03:00
Claudio Ortolina 30e1cfde51 Apply all scrobble rules every 12 hours 2025-08-23 16:31:02 +03:00
Claudio Ortolina 4637f701c0 Reduce cache size in production 2025-08-17 09:34:02 +03:00
Claudio Ortolina c3241b567e Update tailwind from 4.1.11 to 4.1.12 2025-08-15 09:49:42 +03:00
Claudio Ortolina 08d7bba1e3 Update esbuild from 0.25.8 to 0.25.9 2025-08-13 10:30:25 +03:00
Claudio Ortolina e7c6fe799e Apply scrobble rules every 2 hours 2025-08-03 15:42:15 +03:00
Claudio Ortolina 6d12073752 Update dependencies
igniter 0.6.21 => 0.6.22
phoenix_live_view 1.1.0-rc.3 => 1.1.0-rc.4
usage_rules 0.1.22 => 0.1.23
2025-07-23 08:30:30 +01:00
Claudio Ortolina 89b91e0798 Update esbuild from 0.25.7 to 0.25.8 2025-07-20 08:31:44 +01:00
Claudio Ortolina 74fa01cb93 Update esbuild from 0.25.6 to 0.25.7 2025-07-19 08:43:32 +01:00
Claudio Ortolina df3df54a7a Compile JS to es2022 2025-07-17 17:44:06 +01:00
Claudio Ortolina 5e73231767 Move SearchGlobalShortcut to a colocated hook 2025-07-17 17:32:24 +01:00
Claudio Ortolina 3ea2e13863 Upgrade deps, tackle warnings, and update base config 2025-07-17 11:46:19 +01:00
Claudio Ortolina f37719f272 Rename ScrobbleRules.Worker to Worker.ApplyScrobbleRules 2025-07-07 20:14:32 +01:00
Claudio Ortolina 93051d910e Update esbuild from 0.25.5 to 0.25.6 2025-07-07 19:28:15 +01:00
Claudio Ortolina ed61eddf03 Move polyfilling artist IDs to scrobble rules 2025-07-07 09:23:44 +01:00
Claudio Ortolina 40bb95e52d Support translations in Fluxon components 2025-07-05 13:40:45 +01:00
Claudio Ortolina d91685b646 First rough implementation of scrobble rules (Claude)
This plan outlines the implementation of functionality to manage
arbitrary rules for fixing data in the `scrobbled_tracks` table. The
system will support two types of transformations:

1. **Album Rule**: Update the album MusicBrainz ID of all tracks
belonging to a specific album (identified by album title)
2. **Artist Rule**: Update the artist MusicBrainz ID of all tracks
belonging to a specific artist (identified by artist name)

- `scrobbled_tracks` table exists with the following structure:
  - `scrobbled_at_uts` (integer, primary key)
  - `musicbrainz_id` (string) - track MusicBrainz ID
  - `title` (string) - track title
  - `cover_url` (string)
  - `scrobbled_at_label` (string)
  - `artist` (map) - embedded artist data with `musicbrainz_id` and
`name`
  - `album` (map) - embedded album data with `musicbrainz_id` and
`title`
  - `last_fm_data` (map) - raw Last.fm API response

- `LastFm.Track` - Schema for scrobbled tracks
- `LastFm.Artist` - Embedded artist schema
- `LastFm.Album` - Embedded album schema

- Main navigation has Stats, Collection, Wishlist sections
- "More" dropdown contains development tools and utilities
- Uses Phoenix LiveView for interactive components

**File**:
`priv/repo/migrations/YYYYMMDDHHMMSS_create_scrobble_rules.exs`

Create `scrobble_rules` table with:

- `id` (primary key)
- `type` (string) - "album" or "artist"
- `match_value` (string) - album title or artist name to match
- `target_musicbrainz_id` (string) - MusicBrainz ID to set
- `enabled` (boolean) - whether rule is active
- `description` (text) - optional description for the rule
- `inserted_at` (timestamp)
- `updated_at` (timestamp)

Indexes:

- `type, match_value` (compound index for efficient matching)
- `enabled` (for filtering active rules)

**File**: `lib/music_library/scrobble_rules/scrobble_rule.ex`

Create Ecto schema with:

- Field definitions matching migration
- Validations:
  - `type` must be "album" or "artist"
  - `match_value` required and non-empty
  - `target_musicbrainz_id` required and non-empty
  - `enabled` defaults to true
- Changeset functions for create/update operations

**File**: `lib/music_library/scrobble_rules.ex`

Implement context functions:

- `list_scrobble_rules(opts \\ [])` - list all rules with optional
filtering
- `get_scrobble_rule!(id)` - get specific rule by ID
- `create_scrobble_rule(attrs)` - create new rule
- `update_scrobble_rule(rule, attrs)` - update existing rule
- `delete_scrobble_rule(rule)` - delete rule
- `change_scrobble_rule(rule, attrs \\ %{})` - create changeset
- `list_enabled_rules()` - get only enabled rules for worker
- `apply_album_rule(rule)` - apply album transformation
- `apply_artist_rule(rule)` - apply artist transformation
- `apply_all_rules()` - apply all enabled rules

**File**: `lib/music_library_web/components/layouts/app.html.heex`

Add new navigation link in the "More" dropdown:

- Icon: `hero-adjustments-horizontal`
- Label: "Scrobble Rules"
- Route: `/scrobble-rules`
- Position: After "Oban" link, before separator

**File**: `lib/music_library_web/router.ex`

Add new LiveView routes in the authenticated scope:

- `/scrobble-rules` - index page
- `/scrobble-rules/new` - create new rule
- `/scrobble-rules/:id/edit` - edit existing rule

**File**: `lib/music_library_web/live/scrobble_rules_live/index.ex`

Implement LiveView with:

- List view showing all rules with status indicators
- Create/Edit forms with validation
- Delete confirmation
- Filter controls (by type, enabled/disabled)
- Manual rule application triggers
- Real-time updates via PubSub

**Template**:
`lib/music_library_web/live/scrobble_rules_live/index.html.heex`

- Table layout with rule details
- Action buttons (Edit, Delete, Apply)
- Form components for create/edit
- Status indicators for enabled/disabled rules

**File**:
`lib/music_library_web/live/scrobble_rules_live/form_component.ex`

Create reusable form component:

- Type selection (album/artist)
- Match value input with validation
- Target MusicBrainz ID input
- Description textarea
- Enable/disable toggle
- Save/Cancel actions

Where possible, use the components available at
<https://docs.fluxonui.com/1.1.4/overview.html>.

**File**: `lib/music_library/scrobble_rules/worker.ex`

Implement Oban worker:

- Scheduled to run periodically (e.g., every 30 minutes)
- Fetches all enabled rules
- Applies each rule in sequence
- Logs application results
- Handles errors gracefully
- Tracks last application time

**File**: `test/music_library/scrobble_rules_test.exs`

- Test all context functions
- Test rule application logic
- Test edge cases and error handling

**File**: `test/music_library/scrobble_rules/scrobble_rule_test.exs`

- Test schema validations
- Test changeset functions
- Test constraint validations

**File**: `test/music_library_web/live/scrobble_rules_live_test.exs`

- Test LiveView interactions
- Test form submissions
- Test real-time updates
- Test navigation and routing

**File**: `test/music_library/scrobble_rules/worker_test.exs`

- Test job execution
- Test rule application
- Test error handling
- Test scheduling

- Ensure atomic operations when applying rules
- Validate MusicBrainz IDs before applying
- Log all transformations for audit trail

- Index optimization for rule matching
- Batch processing for large datasets
- Rate limiting for external API calls

- Clear feedback on rule application
- Preview mode to show what would change
- Bulk operations for managing multiple rules
- Export/import functionality for rule sets

- Input validation and sanitization
- Rate limiting on rule creation
- Audit logging for all changes

```sql
-- scrobble_rules table
CREATE TABLE scrobble_rules (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  type TEXT NOT NULL CHECK (type IN ('album', 'artist')),
  match_value TEXT NOT NULL,
  target_musicbrainz_id TEXT NOT NULL,
  enabled BOOLEAN NOT NULL DEFAULT TRUE,
  description TEXT,
  inserted_at TIMESTAMP NOT NULL,
  updated_at TIMESTAMP NOT NULL
);

CREATE INDEX idx_scrobble_rules_type_match ON scrobble_rules(type,
match_value);
CREATE INDEX idx_scrobble_rules_enabled ON scrobble_rules(enabled);
```

```
lib/music_library/
├── scrobble_rules/
│   ├── scrobble_rule.ex          # Schema
│   └── worker.ex                 # Oban worker
└── scrobble_rules.ex             # Context

lib/music_library_web/
└── live/
    └── scrobble_rules_live/
        ├── index.ex              # LiveView
        ├── index.html.heex       # Template
        └── form_component.ex     # Form component

priv/repo/migrations/
└── YYYYMMDDHHMMSS_create_scrobble_rules.exs

test/
├── music_library/
│   ├── scrobble_rules_test.exs
│   └── scrobble_rules/
│       ├── scrobble_rule_test.exs
│       └── worker_test.exs
└── music_library_web/
    └── live/
        └── scrobble_rules_live_test.exs
```

1. Database migration and schema
2. Context module with basic CRUD operations
3. LiveView interface for rule management
4. Navigation and routing updates
5. Periodic worker implementation
6. Comprehensive testing
7. Documentation and deployment

This plan ensures a robust, maintainable solution that integrates
seamlessly with the existing Music Library application architecture.
2025-07-03 16:47:08 +01:00
Claudio Ortolina f8628cc2aa Update tailwind from 4.1.10 to 4.1.11 2025-06-29 08:37:39 +01:00
Claudio Ortolina 0739e12ad3 Polyfill scrobbled tracks every hour 2025-06-20 22:43:04 +03:00
Claudio Ortolina 684bf111c1 Use 64MB page size for dev and prod 2025-06-15 11:02:31 +03:00
Claudio Ortolina 98d0fe8ee2 Update tailwind from 4.1.9 to 4.1.10 2025-06-12 16:00:09 +03:00
Claudio Ortolina df00a7270f Update tailwind from 4.1.8 to 4.1.9 2025-06-11 19:32:57 +03:00
Claudio Ortolina 42bf4cb84c Increase cache size for MusicLibrary.Repo 2025-06-01 16:33:50 +01:00