Skip to content

Commit

Permalink
Fix regression introduced by (#473)
Browse files Browse the repository at this point in the history
* Fix aggregate filter by keys
  • Loading branch information
aliel authored and hoh committed Feb 20, 2024
1 parent 7b70409 commit 3a0165a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/aleph/web/controllers/aggregates.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import datetime as dt
import logging
from typing import List, Optional, Dict
from typing import Dict, List, Optional

from aiohttp import web
from pydantic import BaseModel, validator, ValidationError
from aleph.db.accessors.aggregates import get_aggregates_by_owner, refresh_aggregate
from aleph.db.models import AggregateDb
from pydantic import BaseModel, ValidationError, validator
from sqlalchemy import select

from aleph.db.accessors.aggregates import (
get_aggregates_by_owner,
refresh_aggregate,
)
from aleph.db.models import AggregateDb
from .utils import LIST_FIELD_SEPARATOR

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -62,7 +59,8 @@ async def address_aggregate(request: web.Request) -> web.Response:

aggregates = list(
get_aggregates_by_owner(
session=session, owner=address, with_info=query_params.with_info
session=session, owner=address,
with_info=query_params.with_info, keys=query_params.keys
)
)

Expand Down
3 changes: 2 additions & 1 deletion tests/api/test_aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import aiohttp
import pytest

from aleph.db.models import MessageDb

AGGREGATES_URI = "/api/v0/aggregates/{address}.json"
Expand Down Expand Up @@ -100,10 +99,12 @@ async def test_get_aggregates_filter_by_key(

# Multiple keys
address, keys = ADDRESS_1, ["test_target", "test_reference"]
except_key = "test_key"
aggregates = await get_aggregates_expect_success(
ccn_api_client, address=address, keys=",".join(keys), with_info=False
)
assert aggregates["address"] == address
assert except_key not in aggregates["data"]
for key in keys:
assert (
aggregates["data"][key] == EXPECTED_AGGREGATES[address][key]
Expand Down

0 comments on commit 3a0165a

Please sign in to comment.