Skip to content

Conversation

@aaroncameron-wk
Copy link
Collaborator

@aaroncameron-wk aaroncameron-wk commented Feb 9, 2026

Reason for change

The download and view URLs being generated by the CH stream indexer were not taking the filing format into account.

Description of change

Use similar URL construction logic as the company-based indexer.

Correct existing records with:

DO $$
DECLARE
    rows_affected INT;
    total_updated INT := 0;
    batch_size INT := 10;
BEGIN
    LOOP
        WITH target_batch AS (
			SELECT filing_id
			FROM filings
			WHERE format = 'zip' 
			AND status IN ('pending', 'failed')
			AND registry_code = 'CH'
			AND (
				download_url LIKE '%?format=xhtml&%' 
				OR external_view_url LIKE '%?format=xhtml&%' 
			)
			LIMIT batch_size
            FOR UPDATE SKIP LOCKED
        )
        UPDATE filings SET 
			status = 'pending',
			download_url = REPLACE(download_url, '?format=xhtml&', '?format=zip&'),
			external_view_url = REPLACE(external_view_url, '?format=xhtml&', '?format=zip&')
        FROM target_batch
        WHERE filings.filing_id = target_batch.filing_id;

        GET DIAGNOSTICS rows_affected = ROW_COUNT;

        total_updated := total_updated + rows_affected;
        RAISE NOTICE 'Updated batch of % rows... Total so far: %', rows_affected, total_updated;
        
        EXIT WHEN rows_affected = 0;
        
        PERFORM pg_sleep(0.05); 
    END LOOP;

    RAISE NOTICE 'Finished! Total records processed: %', total_updated;
END $$;

Steps to Test

CI

  • Confirm a previously discovered .zip filing generates correctly after correction in DB.
  • Confirm a CH .zip filing discovered by the updated indexer generates correctly.

review:
@Arelle/arelle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants