diff --git a/fastpath/utils/resultstore.py b/fastpath/utils/resultstore.py index 48538ba2ac9dc801b59a01bf2eba008c17c03a05..95ee6a670ee959479a549ca5eaf26901847b3d5c 100644 --- a/fastpath/utils/resultstore.py +++ b/fastpath/utils/resultstore.py @@ -224,13 +224,6 @@ class ResultSet: # Index the tables on their id and replace nans with empty strings. dfs = {t: df.set_index("id").fillna("") for t, df in dfs.items()} - # Drop the pre-computed columns that are used internally for filtering. - dfs[Table.SUT].drop(["name_id"], axis=1, inplace=True) - dfs[Table.SWPROFILE].drop(["name_id"], axis=1, inplace=True) - dfs[Table.BENCHMARK].drop( - ["suitename", "suitename_id"], axis=1, inplace=True - ) - return dfs def to_csv(self, url): @@ -481,7 +474,9 @@ class ResultSet: filters.append( sa.or_( schema.SUT.name.in_(sut), - schema.SUT.name_id.in_(sut), + sa.func.concat(schema.SUT.name, ":", schema.SUT.id).in_( + sut + ), ) ) @@ -489,15 +484,25 @@ class ResultSet: filters.append( sa.or_( schema.SWPROFILE.name.in_(swprofile), - schema.SWPROFILE.name_id.in_(swprofile), + sa.func.concat( + schema.SWPROFILE.name, ":", schema.SWPROFILE.id + ).in_(swprofile), ) ) if benchmark: filters.append( sa.or_( - schema.BENCHMARK.suitename.in_(benchmark), - schema.BENCHMARK.suitename_id.in_(benchmark), + sa.func.concat( + schema.BENCHMARK.suite, "/", schema.BENCHMARK.name + ).in_(benchmark), + sa.func.concat( + schema.BENCHMARK.suite, + "/", + schema.BENCHMARK.name, + ":", + schema.BENCHMARK.id, + ).in_(benchmark), ) ) diff --git a/fastpath/utils/schema.py b/fastpath/utils/schema.py index b966c08e17c716721acb25779ca3a9dd80e3f953..ef331a58476a60f8276481af4c459d665f88778b 100644 --- a/fastpath/utils/schema.py +++ b/fastpath/utils/schema.py @@ -34,22 +34,11 @@ class BENCHMARK(BaseTable, BaseMixin): image = sa.Column(sa.String(SZ_DESC), nullable=False) params_hash = sa.Column(sa.String(SZ_HASH), nullable=False) - # Computed to simplify filtering. - suitename = sa.Column(sa.String(SZ_NAME * 2 + 1)) - suitename_id = sa.Column(sa.String(SZ_NAME * 2 + 12)) - errors = relationship("ERROR", back_populates="benchmark") params = relationship("PARAM", back_populates="benchmark") resultclasses = relationship("RESULTCLASS", back_populates="benchmark") -@sa.event.listens_for(BENCHMARK, "before_insert") -def benchmark_populate_computed_cols(mapper, db, obj): - suitename = f"{obj.suite}/{obj.name}" - obj.suitename = suitename - obj.suitename_id = f"{suitename}:{obj.id}" - - class SWPROFILE(BaseTable, BaseMixin): __tablename__ = "SWPROFILE" @@ -64,18 +53,10 @@ class SWPROFILE(BaseTable, BaseMixin): sysctl = sa.Column(sa.Text, nullable=False) bootscript = sa.Column(sa.Text, nullable=False) - # Computed to simplify filtering. - name_id = sa.Column(sa.String(SZ_NAME + 11)) - errors = relationship("ERROR", back_populates="swprofile") results = relationship("RESULT", back_populates="swprofile") -@sa.event.listens_for(SWPROFILE, "before_insert") -def swprofile_populate_computed_cols(mapper, db, obj): - obj.suitename_id = f"{obj.name}:{obj.id}" - - class CPU(BaseTable, BaseMixin): __tablename__ = "CPU" @@ -175,14 +156,6 @@ class SUT(BaseTable, BaseMixin): product_serial = sa.Column(sa.String(SZ_DESC), nullable=False) mac_addrs_hash = sa.Column(sa.String(SZ_HASH), nullable=False) - # Computed to simplify filtering. - name_id = sa.Column(sa.String(SZ_NAME + 11)) - cpus = relationship("CPU", back_populates="sut") errors = relationship("ERROR", back_populates="sut") results = relationship("RESULT", back_populates="sut") - - -@sa.event.listens_for(SUT, "before_insert") -def sut_populate_computed_cols(mapper, db, obj): - obj.suitename_id = f"{obj.name}:{obj.id}"