Commit 64ce1c2
feat(event-submission): URL-based artist tour import — auto-create artist-scoped pipeline (#322)
Implements the DME side of extrachill-events#320. Adds a moderation
queue (`artist_url_submissions` under $wpdb->base_prefix), four
abilities, four REST routes, and an admin moderation screen.
Abilities (`inc/Abilities/ArtistUrlImportAbilities.php`):
- `data-machine-events/preview-artist-url` — non-destructive probe
via UniversalWebScraper. Returns detected format, event count,
preview list, and a suggested artist (term ID if a similar_text
fuzzy match clears 85%, name otherwise). Logged-in users only.
- `data-machine-events/submit-artist-url` — re-probes server-side
(never trusts client detection) and inserts a row in
`pending_review` (or `scraping_failed`). Logged-in users only.
- `data-machine-events/approve-artist-url-submission` — admin only.
Resolves the artist term (existing id, new name + wp_insert_term,
or the submission's suggested term). Creates pipeline+flow via
`datamachine/create-pipeline` + `datamachine/create-flow` mirroring
the CityAbilities pattern, with universal_web_scraper handler.
Triggers an immediate first run via `datamachine/run-flow`.
- `data-machine-events/reject-artist-url-submission` — admin only.
Marks the row rejected with an optional reason.
SelectionMode alignment: the upsert step pins
`taxonomy_artist_selection = (string) $artist_term_id` (PRE_SELECTED)
and uses `SelectionMode::AI_DECIDES` constants by class reference for
venue/location/festival, `SelectionMode::SKIP` for promoter, category,
post_tag — no bare strings (#320 requirement).
Dedupe: SHA-256 over a normalized URL (lowercased scheme/host,
fragment stripped, trailing slash trimmed except root, default ports
removed). UNIQUE KEY on url_hash; duplicate preview/submit returns
`url_already_tracked`.
REST: `POST /wp-json/datamachine/v1/artist-url/{preview,submit,
{id}/approve,{id}/reject}`. Preview and submit reject direct-browser
navigations (no XHR / JSON Accept header → 404), in the spirit of
Admin moderation UI (`inc/Admin/ArtistUrlSubmissionsAdmin.php`): adds
"Artist URL Imports" under Events. Tabs filter by status (pending
review, approved, rejected, failed scrapes), inline forms for approve
(artist term id OR new name + schedule) and reject (reason). Forms
post to admin-post.php with nonces and delegate to the abilities.
Tests (`tests/Unit/ArtistUrlSubmissionsTableTest.php`,
`tests/Unit/ArtistUrlImportAbilitiesTest.php`): URL normalization,
url_hash dedupe, table CRUD, preview/submit rejection paths,
`artist_required` error from approve when no artist input is
provided, reject sets status + reason. Approve's pipeline-creation
integration is covered by curl verification against a live install
(matrix in the PR body) — recreating Data Machine core abilities in
isolated unit tests would be fake coverage.
The extrachill-events side (form change consuming preview + submit
abilities) ships separately once this merges.
Co-authored-by: homeboy-ci[bot] <266378653+homeboy-ci[bot]@users.noreply.github.com>1 parent cbd7571 commit 64ce1c2
8 files changed
Lines changed: 2547 additions & 0 deletions
File tree
- inc
- Abilities
- Admin
- Api
- Controllers
- Core
- tests/Unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
| |||
234 | 238 | | |
235 | 239 | | |
236 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
237 | 246 | | |
238 | 247 | | |
239 | 248 | | |
| |||
484 | 493 | | |
485 | 494 | | |
486 | 495 | | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
487 | 501 | | |
488 | 502 | | |
489 | 503 | | |
| |||
606 | 620 | | |
607 | 621 | | |
608 | 622 | | |
| 623 | + | |
609 | 624 | | |
610 | 625 | | |
611 | 626 | | |
| |||
0 commit comments