Skip to content

Commit

Permalink
fix bug 972612 - is_gc_count should be per-adu r=selenamarie
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmer committed Feb 14, 2014
1 parent d52bfb7 commit e56e67c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
@@ -0,0 +1,42 @@
"""fix bug 972612 - is_gc_count should be per-ADU
Revision ID: c1ac31c8fea
Revises: 1aa9adb91413
Create Date: 2014-02-13 15:14:23.916163
"""

# revision identifiers, used by Alembic.
revision = 'c1ac31c8fea'
down_revision = '491cdcf9f97c'

import datetime

from alembic import op
from socorro.lib import citexttype, jsontype, buildtype
from socorro.lib.migrations import fix_permissions, load_stored_proc

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




def upgrade():
load_stored_proc(op, ['update_gccrashes.sql'])
op.execute(""" TRUNCATE gccrashes """)
op.alter_column(u'gccrashes', sa.Column(u'version_string', sa.REAL()))
now = datetime.datetime.utcnow()
for backfill_date in [
(now - datetime.timedelta(days=days)).strftime("%Y-%m-%d")
for days in range(1,30)]:
op.execute(""" SELECT backfill_gccrashes('%s') """ % backfill_date)
op.execute(""" COMMIT """)



def downgrade():
load_stored_proc(op, ['update_gccrashes.sql'])
op.alter_column(u'gccrashes', sa.Column(u'version_string', sa.INT()))
2 changes: 1 addition & 1 deletion socorro/external/postgresql/models.py
Expand Up @@ -1469,7 +1469,7 @@ class GCCrashes(DeclarativeBase):
report_date = Column(u'report_date', TIMESTAMP(timezone=True), nullable=False)
product_version_id = Column(u'product_version_id', INTEGER(), nullable=False)
build = Column(u'build', NUMERIC(), nullable=True)
is_gc_count = Column(u'is_gc_count', INTEGER(), nullable=False)
is_gc_count = Column(u'is_gc_count', NUMERIC(), nullable=False)

__mapper_args__ = {"primary_key": (report_date, product_version_id, build,
is_gc_count)}
Expand Down
Expand Up @@ -52,13 +52,15 @@ WITH raw_crash_filtered AS (
SELECT updateday
, product_version_id
, build
, sum(CASE WHEN r.is_garbage_collecting = '1' THEN 1 ELSE 0 END) as is_gc_count
, sum(CASE WHEN r.is_garbage_collecting = '1' THEN 1 ELSE 0 END)::real / sum(adu_count)::real as is_gc_count
FROM reports_clean
JOIN product_versions USING (product_version_id)
JOIN product_adu USING (product_version_id)
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)
AND product_versions.build_type = 'nightly'
AND tstz_between(adu_date, build_date, sunset_date)
GROUP BY build, product_version_id
ORDER BY build;

Expand Down

0 comments on commit e56e67c

Please sign in to comment.