Skip to content

Commit

Permalink
Fixes bugs in processing unpivoted results
Browse files Browse the repository at this point in the history
  • Loading branch information
rcboufleur committed Dec 8, 2024
1 parent 38c12fd commit 8acfdd0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 46 deletions.
24 changes: 1 addition & 23 deletions python/lsst/consdb/efd_transform/dao/exposure_efd_unpivoted.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pandas
from dao.base import DBBase
from sqlalchemy.sql import and_, select
from sqlalchemy.sql import select


class ExposureEfdUnpivotedDao(DBBase):
Expand Down Expand Up @@ -41,28 +41,6 @@ def get_by_exposure_id(self, exposure_id: int):

return rows

def get_by_exposure_id_parameter(self, exposure_id: int, parameter: str):
"""
Retrieves rows from the "exposure_efd_unpivoted" table based on
exposure ID and parameter.
Args:
exposure_id (int): The exposure ID.
parameter (str): The parameter name.
Returns:
list: A list of dictionaries representing the rows retrieved from
the table.
"""
stm = select(self.tbl.c).where(
and_(self.tbl.c.exposure_id == exposure_id, self.tbl.c.parameter == parameter)
)

rows = self.fetch_all_dict(stm)

return rows

def count(self):
"""
Returns the count of rows in the "exposure_efd_unpivoted" table.
Expand Down
22 changes: 1 addition & 21 deletions python/lsst/consdb/efd_transform/dao/visit_efd_unpivoted.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pandas
from dao.base import DBBase
from sqlalchemy.sql import and_, select
from sqlalchemy.sql import select


class VisitEfdUnpivotedDao(DBBase):
Expand Down Expand Up @@ -37,26 +37,6 @@ def get_by_visit_id(self, visit_id: int):

return rows

def get_by_visit_id_parameter(self, visit_id: int, parameter: str):
"""
Retrieve rows from the table based on visit_id and parameter.
Args:
visit_id (int): The visit_id to filter the rows.
parameter (str): The parameter to filter the rows.
Returns:
list: A list of rows matching the visit_id and parameter.
"""
stm = select(self.tbl.c).where(
and_(self.tbl.c.visit_id == visit_id, self.tbl.c.parameter == parameter)
)

rows = self.fetch_all_dict(stm)

return rows

def count(self):
"""
Get the count of rows in the table.
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/consdb/efd_transform/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def process_interval(
result_vis_unpivoted.append(
{
"visit_id": visit["id"],
"property": topic,
"property": column["name"],
"field": col,
"value": column_value,
}
Expand Down Expand Up @@ -330,7 +330,7 @@ def process_interval(
)
count["exposures_unpivoted"] = affected_rows
self.log.info(f"Database rows affected: {affected_rows}")
# del result_exp_unpivoted
del result_exp_unpivoted

# ingesting visit
results = []
Expand Down

0 comments on commit 8acfdd0

Please sign in to comment.