Skip to content

Commit

Permalink
refactor: format files
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtobac committed Dec 13, 2023
1 parent fbe48ca commit abac54d
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 16 deletions.
83 changes: 82 additions & 1 deletion crunchbase/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crunchbase/provider/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

logger = logging.getLogger(__name__)


def search(body):
logger.debug(f'Search request: {body["query"]}')
try:
Expand Down
14 changes: 5 additions & 9 deletions crunchbase/provider/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def __init__(self, api_key, search_limit):
self.search_limit = search_limit

def get_search_limit(self):
return self.search_limit
return self.search_limit

def get(self, params={}):
response = requests.get(self.API_URL, params=params)

Expand All @@ -24,14 +24,10 @@ def get(self, params={}):
raise UpstreamProviderError(message)

return response.json()

def autocomplete(self, term):
# @see: https://data.crunchbase.com/docs/using-autocomplete-api
params = {
"query": term,
"limit": self.search_limit,
"user_key": self.user_key
}
params = {"query": term, "limit": self.search_limit, "user_key": self.user_key}
return self.get(params)


Expand All @@ -43,4 +39,4 @@ def get_client():
if not client:
client = CrunchbaseApiClient(api_key, search_limit)

return client
return client
15 changes: 9 additions & 6 deletions crunchbase/provider/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

logger = logging.getLogger(__name__)


def serialize_results(data):
# debug data
logger.debug(f"Raw data: {data}")
Expand All @@ -12,12 +13,14 @@ def serialize_results(data):
results = data.get("entities", [])
for entity in results:
identifier = entity.pop("identifier", {})
serialized_data.append({
"text": entity.pop("short_description"),
"title": identifier.pop("value"),
"url": f"https://www.crunchbase.com/{identifier.pop('entity_def_id')}/{identifier.pop('permalink')}",
"id": identifier.pop("uuid"),
})
serialized_data.append(
{
"text": entity.pop("short_description"),
"title": identifier.pop("value"),
"url": f"https://www.crunchbase.com/{identifier.pop('entity_def_id')}/{identifier.pop('permalink')}",
"id": identifier.pop("uuid"),
}
)
return serialized_data


Expand Down
3 changes: 3 additions & 0 deletions crunchbase/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ python-dotenv = "^1.0.0"
gunicorn = "^21.2.0"


[tool.poetry.group.dev.dependencies]
black = "^23.12.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit abac54d

Please sign in to comment.