Skip to content

Commit

Permalink
Merge pull request mozilla-services#1309 from selenamarie/bug886917-g…
Browse files Browse the repository at this point in the history
…c-in-tcbs_build

bug 886917 update tcbs_build for is_gc_count
  • Loading branch information
selenamarie committed Jun 26, 2013
2 parents dd58391 + db2716f commit a1d57ff
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
30 changes: 30 additions & 0 deletions alembic/versions/4d4b48f86d4b_bug_886917_add_is_gc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""bug 886917 Add is_gc_count to tcbs_build report
Revision ID: 4d4b48f86d4b
Revises: 2b285e76f71d
Create Date: 2013-06-25 11:29:22.679634
"""

# revision identifiers, used by Alembic.
revision = '4d4b48f86d4b'
down_revision = '2b285e76f71d'

import os
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
from sqlalchemy import types
from sqlalchemy.sql import table, column

def upgrade():
app_path=os.getcwd()
procs = [
'update_tcbs_build.sql'
]
for myfile in [app_path + '/socorro/external/postgresql/raw_sql/procs/' + line for line in procs]:
with open(myfile, 'r') as file:
op.execute(file.read())

def downgrade():
pass
24 changes: 24 additions & 0 deletions socorro/external/postgresql/raw_sql/procs/update_tcbs_build.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ INSERT INTO tcbs_build (
process_type, release_channel,
report_count, win_count, mac_count, lin_count, hang_count,
startup_count
, is_gc_count
)
WITH raw_crash_filtered AS (
SELECT
uuid
, json_object_field_text(r.raw_crash, 'IsGarbageCollecting') as is_garbage_collecting
FROM
raw_crashes r
WHERE
date_processed::date = updateday
)
SELECT signature_id, build_date(build),
updateday, product_version_id,
Expand All @@ -48,9 +58,11 @@ SELECT signature_id, build_date(build),
sum(case when os_name = 'Linux' THEN 1 else 0 END),
count(hang_id),
sum(case when uptime < INTERVAL '1 minute' THEN 1 else 0 END)
, sum(CASE WHEN r.is_garbage_collecting = '1' THEN 1 ELSE 0 END) as gc_count
FROM reports_clean
JOIN product_versions USING (product_version_id)
JOIN products USING ( product_name )
LEFT JOIN raw_crash_filtered r ON r.uuid::text = reports_clean.uuid
WHERE utc_day_is(date_processed, updateday)
AND tstz_between(date_processed, build_date, sunset_date)
-- 7 days of builds only
Expand All @@ -69,6 +81,16 @@ INSERT INTO tcbs_build (
process_type, release_channel,
report_count, win_count, mac_count, lin_count, hang_count,
startup_count
, is_gc_count
)
WITH raw_crash_filtered AS (
SELECT
uuid
, json_object_field_text(r.raw_crash, 'IsGarbageCollecting') as is_garbage_collecting
FROM
raw_crashes r
WHERE
date_processed::date = updateday
)
SELECT signature_id, build_date(build),
updateday, rapid_beta_id,
Expand All @@ -79,9 +101,11 @@ SELECT signature_id, build_date(build),
sum(case when os_name = 'Linux' THEN 1 else 0 END),
count(hang_id),
sum(case when uptime < INTERVAL '1 minute' THEN 1 else 0 END)
, sum(CASE WHEN r.is_garbage_collecting = '1' THEN 1 ELSE 0 END) as gc_count
FROM reports_clean
JOIN product_versions USING (product_version_id)
JOIN products USING ( product_name )
LEFT JOIN raw_crash_filtered r ON r.uuid::text = reports_clean.uuid
WHERE utc_day_is(date_processed, updateday)
AND tstz_between(date_processed, build_date, sunset_date)
-- 7 days of builds only
Expand Down

0 comments on commit a1d57ff

Please sign in to comment.