Skip to content

Update contributions_mv to include push events with target_type

See &19098 for more context

Before implementing target_type assignment for push events, we need to update the Clickhouse materialized views to handle both:

  • Existing push events (without target_type)
  • New push events (with target_type)

Implementation Guide

  1. Update contributions/contributions_new tables in Clickhouse to include events where: action = 5 AND (target_type = '' OR target_type = 'Project')
CREATE MATERIALIZED VIEW IF NOT EXISTS contributions_new_mv
    TO contributions_new
AS
SELECT id,
       argMax(path, events_new.updated_at)             as path,
       argMax(author_id, events_new.updated_at)        as author_id,
       argMax(target_type, events_new.updated_at)      as target_type,
       argMax(action, events_new.updated_at)           as action,
       argMax(date(created_at), events_new.updated_at) as created_at,
       max(events_new.updated_at)                      as updated_at
FROM events_new
WHERE (("events"."action" = 6 AND "events"."target_type" = '')
    OR ("events"."action" = 5 AND ("events"."target_type" = '' OR "events"."target_type" = 'Project'))
    OR ("events_new"."action" IN (1, 3, 7, 12)
        AND "events_new"."target_type" IN ('MergeRequest', 'Issue', 'WorkItem')))
GROUP BY id
Edited by Shane Maglangit