Skip to content

Commit

Permalink
Use last 100 commits in distribution history (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Jun 15, 2021
1 parent 820918d commit cf495e7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions conbench/entities/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Distribution(Base, EntityMixin):
first_timestamp = NotNull(s.DateTime(timezone=False))
last_timestamp = NotNull(s.DateTime(timezone=False))
observations = NotNull(s.Integer, check("observations>=1"))
limit = Nullable(s.Integer)


s.Index(
Expand Down Expand Up @@ -136,6 +137,7 @@ def update_distribution(repository, sha, summary, limit):
values = dict(distribution)
machine_hash = values.pop("hash")
values["machine_hash"] = machine_hash
values["limit"] = limit

with engine.connect() as conn:
conn.execute(
Expand Down
2 changes: 1 addition & 1 deletion conbench/entities/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def create(data):
bulk.append(Time(result=x, summary_id=summary.id, iteration=i + 1))
Time.bulk_save_objects(bulk)

update_distribution(repository, sha, summary, 1000)
update_distribution(repository, sha, summary, 100)

return summary

Expand Down
28 changes: 28 additions & 0 deletions migrations/versions/2d922b652c91_add_limit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from alembic import op
import sqlalchemy as sa
from sqlalchemy import MetaData


revision = "2d922b652c91"
down_revision = "2252bb39c5cf"
branch_labels = None
depends_on = None


def upgrade():
op.add_column("distribution", sa.Column("limit", sa.Integer(), nullable=True))

connection = op.get_bind()
meta = MetaData()
meta.reflect(bind=connection)
distribution_table = meta.tables["distribution"]

connection.execute(
distribution_table.update()
.where(distribution_table.c.limit == None) # noqa
.values(limit=1000)
)


def downgrade():
op.drop_column("distribution", "limit")

0 comments on commit cf495e7

Please sign in to comment.