Public
Authored by Sean McGivern

Count merged MRs by assignee by month

Edited
count_mrs.rb 462 Bytes
  • This generates the following SQL:

    SELECT COUNT(*) AS count_all
    	,"username" AS username
    FROM "merge_requests"
    INNER JOIN "projects" ON "projects"."id" = "merge_requests"."target_project_id"
    INNER JOIN "merge_request_metrics" ON "merge_request_metrics"."merge_request_id" = "merge_requests"."id"
    LEFT JOIN project_features ON projects.id = project_features.project_id
    LEFT JOIN users ON merge_requests.assignee_id = users.id
    WHERE "projects"."namespace_id" IN (
    		WITH RECURSIVE "base_and_descendants" AS (
    				SELECT "namespaces".*
    				FROM "namespaces"
    				WHERE "namespaces"."type" IN ('Group')
    					AND "namespaces"."id" = 9970
    				
    				UNION
    				
    				SELECT "namespaces".*
    				FROM "namespaces"
    					,"base_and_descendants"
    				WHERE "namespaces"."type" IN ('Group')
    					AND "namespaces"."parent_id" = "base_and_descendants"."id"
    				)
    		SELECT "id"
    		FROM "base_and_descendants" AS "namespaces"
    		)
    	AND (
    		EXISTS (
    			SELECT 1
    			FROM "project_authorizations"
    			WHERE "project_authorizations"."user_id" = 443319
    				AND (project_authorizations.project_id = projects.id)
    			)
    		OR projects.visibility_level IN (
    			10
    			,20
    			)
    		)
    	AND (
    		(
    			projects.visibility_level > 0
    			AND (
    				"project_features"."merge_requests_access_level" IS NULL
    				OR "project_features"."merge_requests_access_level" >= (20)
    				OR (
    					"project_features"."merge_requests_access_level" = 10
    					AND EXISTS (
    						SELECT 1
    						FROM "project_authorizations"
    						WHERE "project_authorizations"."user_id" = 443319
    							AND (project_authorizations.project_id = projects.id)
    							AND (project_authorizations.access_level >= 20)
    						)
    					)
    				)
    			)
    		OR (
    			projects.visibility_level = 0
    			AND (
    				"project_features"."merge_requests_access_level" IS NULL
    				OR "project_features"."merge_requests_access_level" >= 10
    				)
    			AND EXISTS (
    				SELECT 1
    				FROM "project_authorizations"
    				WHERE "project_authorizations"."user_id" = 443319
    					AND (project_authorizations.project_id = projects.id)
    					AND (project_authorizations.access_level >= 20)
    				)
    			)
    		)
    	AND (
    		"merge_request_metrics"."merged_at" BETWEEN '2019-03-01 00:00:00'
    			AND '2019-04-01 00:00:00'
    		)
    GROUP BY "username"
  • 2019-02:

    Alexand,1
    GotenXiao,1
    abrandl,1
    adrielsantiago,1
    afontaine,1
    ahanselka,1
    ahmadsherif,1
    andrewn,1
    bbodenmiller,1
    blabuschagne,1
    brodock,1
    cab105,1
    danielgruesso,1
    danieljg,1
    dblessing,1
    dcoy1,1
    dimitrieh,1
    glensc,1
    groulot,1
    gtsiolis,1
    jeremy,1
    jivanvl,1
    lmcandrew,1
    matejlatin,1
    max-wittig,1
    proglottis,1
    pslaughter,1
    reprazent,1
    skarbek,1
    splattael,1
    tatkins,1
    tkuah,1
    tmaczukin,1
    tnikic,1
    tpazitny,1
    tszuromi,1
    viktomas,1
    winh,1
    DylanGriffith,2
    Ravlen,2
    WarheadsSE,2
    hphilipps,2
    jlenny,2
    shampton,2
    tauriedavis,2
    psimyn,3
    sbigelow,3
    theoretick,3
    zj,3
    lbennett,4
    meks,4
    mikelewis,4
    timzallmann,4
    gonzoyumo,5
    leipert,5
    ddavison,6
    nolith,6
    rdavila,6
    brytannia,7
    MadLittleMods,8
    ClemMakesApps,9
    gitlab-release-tools-bot,9
    at.ramya,10
    jacobvosmaer-gitlab,10
    toon,10
    dzaporozhets,11
    sliaquat,11
    johncai,13
    markglenfletcher,13
    mlapierre,14
    steveazz,15
    fcatteau,16
    pokstad1,17
    annabeldunstone,18
    DouweM,19
    jameslopez,19
    kushalpandya,20
    ibaum,21
    yorickpeterse,21
    fatihacet,22
    plafoucriere,24
    marcia,25
    twk3,25
    marin,27
    godfat,29
    ayufan,31
    grzesiek,38
    rspeicher,38
    stanhu,42
    dbalexandre,44
    filipa,49
    ,55
    nick.thomas,58
    axil,59
    eread,59
    smcgivern,66
    rymai,70
    iamphill,92
    Edited by Sean McGivern
  • 2019-03:

    LordMike,1
    afontaine,1
    alejandro,1
    andy.wilson,1
    andyvolpe,1
    clenneville,1
    dany.jupille,1
    dcoy1,1
    dennis,1
    dosuken123,1
    ekigbo,1
    haynes,1
    jarv,1
    liunate,1
    lmcandrew,1
    markrian,1
    matteeyah,1
    maxmati,1
    pedroms,1
    sarahghp,1
    sengelhard,1
    siriusdely,1
    skarbek,1
    splattael,1
    tigerwnz,1
    tommy.morgan,1
    viktomas,1
    Ravlen,2
    dimitrieh,2
    erushton,2
    groulot,2
    proglottis,2
    toon,2
    zeffmorgan,2
    ahmadsherif,3
    leipert,3
    meks,3
    psimyn,3
    rverissimo,3
    winh,3
    MadLittleMods,4
    abrandl,4
    igor.drozdov,4
    vzagorodny,4
    andrewn,5
    lbennett,5
    rdavila,5
    brytannia,6
    nolith,6
    at.ramya,9
    dzaporozhets,9
    sliaquat,9
    tauriedavis,9
    WarheadsSE,10
    timzallmann,11
    jacobvosmaer-gitlab,12
    markglenfletcher,12
    ddavison,13
    marin,13
    tmaczukin,14
    annabeldunstone,15
    jameslopez,15
    mlapierre,15
    steveazz,16
    zj,16
    johncai,17
    gitlab-release-tools-bot,18
    yorickpeterse,18
    gonzoyumo,20
    pokstad1,22
    fatihacet,23
    mikelewis,24
    dbalexandre,25
    ibaum,27
    mikegreiling,29
    theoretick,32
    twk3,32
    fcatteau,34
    marcia,34
    grzesiek,38
    plafoucriere,38
    rspeicher,43
    kushalpandya,44
    DouweM,45
    ,45
    ClemMakesApps,47
    godfat,47
    ayufan,48
    nick.thomas,52
    filipa,55
    stanhu,62
    rymai,66
    axil,67
    smcgivern,67
    eread,70
    iamphill,154
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment