Skip to content

Commit

Permalink
Implement response_type correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ugyballoons committed Jan 7, 2025
1 parent ae45418 commit 6fec4af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions python/lsst/rubintv/analysis/service/commands/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class AggregateQueryCommand(BaseCommand):
data_ids : list[tuple[int, int]] | None
Specific (day_obs, seq_num) pairs to filter rows.
response_type : str
The type of response returned, defaulting to "aggregate".
The type of response returned, defaulting to "aggregated".
"""

database: str
Expand All @@ -242,7 +242,7 @@ class AggregateQueryCommand(BaseCommand):
global_query: dict | None = None
day_obs: str | None = None
data_ids: list[tuple[int, int]] | None = None
response_type: str = "aggregate"
response_type: str = "aggregated"

def build_contents(self, data_center: DataCenter) -> dict:
"""Query the database to perform the specified aggregate operation on each column."""

Check failure on line 248 in python/lsst/rubintv/analysis/service/commands/db.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

W505

doc line too long (93 > 79 characters)
Expand All @@ -268,10 +268,9 @@ def build_contents(self, data_center: DataCenter) -> dict:
# Extract the aggregate result from the query result
result[column] = query_result.result.get(self.query_type.lower(), 0)

# Return the results in the expected format
return {
"schema": self.database,
self.response_type: result,
self.query_type: result,
}


Expand Down
12 changes: 6 additions & 6 deletions tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def test_count_rows(self):
"query_type": "count",
},
}
content = self.execute_command(command, "aggregate")
data = content["aggregate"]
content = self.execute_command(command, "aggregated")
data = content["count"]
self.assertEqual(data, {columns[0]: [8], columns[1]: [8]})

def test_sum_rows(self):
Expand All @@ -68,8 +68,8 @@ def test_sum_rows(self):
"query_type": "sum",
},
}
content = self.execute_command(command, "aggregate")
data = content["aggregate"]
content = self.execute_command(command, "aggregated")
data = content["sum"]
self.assertEqual(data, {columns[0]: [440.0], columns[1]: [50.0]})

def test_max_rows(self):
Expand All @@ -85,8 +85,8 @@ def test_max_rows(self):
"query_type": "max",
},
}
content = self.execute_command(command, "aggregate")
data = content["aggregate"]
content = self.execute_command(command, "aggregated")
data = content["max"]
self.assertEqual(data, {columns[0]: [100.0], columns[1]: [50.0]})


Expand Down

0 comments on commit 6fec4af

Please sign in to comment.