Skip to content

Commit

Permalink
slim down objects before sending them to yente
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Dec 19, 2022
1 parent 578d806 commit c71d3c9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nomenklatura/enrich/yente.py
@@ -1,7 +1,7 @@
import os
import logging
from banal import ensure_list
from typing import Any, Generator, Optional
from typing import Any, Generator, Optional, Dict, List
from urllib.parse import urljoin
from followthemoney.types import registry
from followthemoney.namespace import Namespace
Expand Down Expand Up @@ -48,11 +48,17 @@ def match(self, entity: CE) -> Generator[CE, None, None]:
cache_key = f"{url}:{entity.id}"
response = self.cache.get_json(cache_key, max_age=self.cache_days)
if response is None:
props: Dict[str, List[str]] = {}
for prop in entity.iterprops():
if prop.type == registry.entity:
continue
if prop.matchable:
props[prop.name] = entity.get(prop)
data = {
"queries": {
"entity": {
"schema": entity.schema.name,
"properties": entity.properties,
"properties": props,
}
}
}
Expand Down

0 comments on commit c71d3c9

Please sign in to comment.