Skip to content

Instantly share code, notes, and snippets.

@yvanzo
yvanzo / country_from_areas.sql
Created July 25, 2020 21:28
Get country code for more than one area
WITH RECURSIVE area_descendants AS (
SELECT entity0 AS parent, entity1 AS descendant, 1 AS depth
FROM l_area_area laa
JOIN link ON laa.link = link.id
WHERE link.link_type = 356
AND entity1 IN (5099, 8127)
UNION
SELECT entity0 AS parent, descendant, (depth + 1) AS depth
FROM l_area_area laa
JOIN link ON laa.link = link.id
@yvanzo
yvanzo / country_from_area.sql
Created July 25, 2020 21:15
Get country code (US) for Chicago (5099)
WITH RECURSIVE area_descendants AS (
SELECT entity0 AS parent, entity1 AS descendant, 1 AS depth
FROM l_area_area laa
JOIN link ON laa.link = link.id
WHERE link.link_type = 356
AND entity1 = 5099
UNION
SELECT entity0 AS parent, descendant, (depth + 1) AS depth
FROM l_area_area laa
JOIN link ON laa.link = link.id
@yvanzo
yvanzo / list_artist_edits.sql
Last active June 29, 2020 18:21
Select unrelated recording-of relationship edits in editing history of artists, recordings and releases
WITH
first_edit AS (
SELECT id FROM edit WHERE id > 70000000 AND open_time >= '2020-06-15'::timestamp ORDER BY id ASC LIMIT 1
),
last_edit AS (
SELECT id FROM edit WHERE id > 70000000 AND open_time <= '2020-06-29T16:30'::timestamp ORDER BY id DESC LIMIT 1
),
recording_artist AS (
SELECT r.id recording, acn.artist
FROM recording r
@yvanzo
yvanzo / custom-db-options.yml
Created May 14, 2020 14:43
Pass custom configuration parmeters and options to Postgres
version: '3.1'
# Description: Pass custom configuration parmeters and options to Postgres
services:
db:
command: postgres -c "shared_buffers=4096MB" -c "shared_preload_libraries=pg_amqp.so"
@yvanzo
yvanzo / ise1474.html
Created May 4, 2020 17:49
ISE when searching oldest “Edit relaltionship” edits / PR #1474
<h1>Internal Server Error</h1>
<p><strong>Oops, something went wrong!</strong></p>
<p>
<strong>Error message: </strong>
<code>(No details about this error are available)</code>
@yvanzo
yvanzo / reindex-all-but-annotation.sh
Last active April 28, 2020 18:39
Rebuild search indexes for all but annotation
for i in area artist cdstub editor event instrument label place recording release release-group series tag url work
do
echo "Start reindexing $i..."
sudo docker-compose exec indexer python -m sir reindex --entity-type "$i"
done
diff --git a/yarn.lock b/yarn.lock
index 71c4be127d..51329a3c80 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1071,11 +1071,6 @@ abab@^2.0.0:
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a"
integrity sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg==
-abbrev@1:
- version "1.1.1"
@yvanzo
yvanzo / clean-tag.sh
Created April 1, 2020 12:16
Clean errant tags from both local working copy and remote repository
#!/bin/sh
for oldtag in delete next-2011-04-14 ocharles/v-2011-05-27-ngs-hotfixes v-20110711-schema-change v-2020-03-30
do
git tag -d "$oldtag"
git push origin :refs/tags/"$oldtag" -f # assuming "origin" points to your own remote repository
done
@yvanzo
yvanzo / reindex-instrument-47ffd57.excerpt.log
Created January 27, 2020 19:17
python -m sir -d reindex --entity-type=instrument
PoolWorker-1 2020-01-27 19:13:35,829 DEBUG: Importing <class 'sir.schema.modelext.CustomInstrument'> (1, None)
PoolWorker-1 2020-01-27 19:13:35,833 DEBUG: Loading <generator object <genexpr> at 0x7fa44828cd20> instead of begin_date on <class 'mbdata.models.InstrumentAlias'>
PoolWorker-1 2020-01-27 19:13:35,833 DEBUG: Loading <generator object <genexpr> at 0x7fa44828cd70> instead of end_date on <class 'mbdata.models.InstrumentAlias'>
PoolWorker-1 2020-01-27 19:13:35,833 DEBUG: Loading only ['name', 'locale', 'sort_name', 'type', 'primary_for_locale', 'id', 'begin_date_year', 'begin_date_month', 'begin_date_day', 'end_date_year', 'end_date_month', 'end_date_day'] on <class 'mbdata.models.InstrumentAlias'>
PoolWorker-1 2020-01-27 19:13:35,833 DEBUG: Deferring begin_date on Mapper|InstrumentAlias|instrument_alias
PoolWorker-1 2020-01-27 19:13:35,833 ERROR: Failed to import instrument with id in bounds (1, None)
PoolWorker-1 2020-01-27 19:13:35,834 ERROR: _wildcard_token
Traceback (most recent call last):
@yvanzo
yvanzo / config.ini
Created August 14, 2019 13:43
Lesser intensive indexer is more time for other services to run at the same time
database]
dbname = musicbrainz_db
host = db
password = ${POSTGRES_PASSWORD}
port = 5432
user = ${POSTGRES_USER}
[solr]
uri = http://search:8983/solr
batch_size = 60