Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

civiCRM email summary report etl #856

Merged
merged 22 commits into from
Feb 4, 2022
Merged

civiCRM email summary report etl #856

merged 22 commits into from
Feb 4, 2022

Conversation

HazalCiplak
Copy link
Member

@HazalCiplak
Copy link
Member Author

Hi @de-code, I am not pretty sure about the authentication key handling in the code, it would be good to look at it together when you find time today or tomorrow before deploying.

requirements.txt Outdated Show resolved Hide resolved


def get_civicrm_credential(key_name: str):
secret_file = get_env_var_or_use_default(CIVICRM_KEY_SECRET_FILE_PATH_ENV, "")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess by this time, the environment variable is required?

Is that the same configuration that we use for the current Civi API access or is that something new?

def get_civicrm_credential(key_name: str):
if key_name == "api_key":
return read_file_content(
get_env_var_or_use_default(CIVICRM_API_KEY_FILE_PATH_ENV, "")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make it so the environment variable is required? It would make error messages more informative.

return data_configuration


def get_civicrm_credential(key_name: str):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: Maybe rather than passing in the key name, we could just pass in the env variable name?
Otherwise at the moment it isn't clear what the accepted key names are.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or alternatively these could just be two separate functions. They don't really share any code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used env var name

return response.json()


def format_email_report(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: usually I would associate a format function with a text output. Perhaps another name could make it more clear? Maybe transform? And maybe it could say from what to what format do we transform it?


LOGGER = logging.getLogger(__name__)

CIVICRM_KEY_SECRET_FILE_PATH_ENV = "CIVICRM_KEY_SECRET_FILE_PATH"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this can now be removed? (And any other related mention in other files)



def get_civicrm_credential(env_var_name: str):
if env_var_name == "CIVICRM_API_KEY_FILE_PATH_ENV":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You no longer need this condition, now that you pass in the env var name.
You would just use the env var name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean creating two different function ? Because I did not get the point of not using condition (if statement)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating two separate functions was the alternative...

Buf if we pass in the environment variable name to the function then we can just use it, e.g.:

    return read_file_content(get_required_env_var(env_var_name))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes sorry, my mind is a bit full atm.

@HazalCiplak HazalCiplak merged commit 4139ccc into develop Feb 4, 2022
@HazalCiplak HazalCiplak deleted the civi branch February 4, 2022 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants