Skip to content

Commit

Permalink
fixing linting for analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
VineetBala-AOT committed Jan 10, 2024
1 parent e7818e6 commit f934749
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
13 changes: 7 additions & 6 deletions analytics-api/src/analytics_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import os
import sys

from typing import Union
from dotenv import find_dotenv, load_dotenv

# this will load all the envars from a .env file located in the project root (api)
load_dotenv(find_dotenv())


def get_named_config(environment: str | None) -> '_Config':
def get_named_config(environment: Union[str, None]) -> '_Config':
"""
Retrieve a configuration object by name. Used by the Flask app factory.
Expand All @@ -38,16 +39,16 @@ def get_named_config(environment: str | None) -> '_Config':
"""
config_mapping = {
'development': DevConfig,
'default': ProdConfig,
'staging': ProdConfig,
'default': ProdConfig,
'staging': ProdConfig,
'production': ProdConfig,
'testing': TestConfig,
'testing': TestConfig,
}
try:
print(f'Loading configuration: {environment}...')
return config_mapping[environment]()
except KeyError:
raise KeyError(f'Configuration "{environment}" not found.')
except KeyError as e:
raise KeyError(f'Configuration "{environment}" not found.') from e


class _Config(): # pylint: disable=too-few-public-methods
Expand Down
18 changes: 9 additions & 9 deletions analytics-api/src/analytics_api/models/request_type_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ def get_survey_result(
return survey_result.all()
# Check if there are records in survey_response before executing the final query which fetches reponses
# even if the available_response table is not yet populated.
elif survey_response_exists:
if survey_response_exists:
survey_result = (db.session.query((survey_question.c.position).label('position'),
(survey_question.c.label).label('question'),
func.json_agg(func.json_build_object('value',
survey_response.c.value,
'count',
survey_response.c.response))
.label('result'))
.join(survey_response, survey_response.c.request_key == survey_question.c.key)
.group_by(survey_question.c.position, survey_question.c.label))
(survey_question.c.label).label('question'),
func.json_agg(func.json_build_object('value',
survey_response.c.value,
'count',
survey_response.c.response))
.label('result'))
.join(survey_response, survey_response.c.request_key == survey_question.c.key)
.group_by(survey_question.c.position, survey_question.c.label))

return survey_result.all()

Expand Down

0 comments on commit f934749

Please sign in to comment.