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

Updated docstring to google format. #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions rctab/daily_routine_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ def __exit__(
def datetime_utcnow() -> datetime:
"""Returns the current date and time in the UTC timezone.

Returns
-------
datetime
current UTC date and time
Returns:
the current UTC date and time
"""
# This can be patched for testing more easily than datetime

Expand Down Expand Up @@ -105,12 +103,9 @@ async def send_summary_email(

Items in the jinja2 template are replaced with those in template_data.

Parameters
----------
recipients : List[str]
list of email addresses of recipients
since_this_datetime : Optional[datetime], optional
include information since this date and time, by default None
Args:
recipients : list of email addresses of recipients.
since_this_datetime : include information since this date and time, by default None.
"""
# pylint: disable=invalid-name
template_name = "daily_summary.html"
Expand Down Expand Up @@ -229,10 +224,8 @@ async def routine_tasks() -> None:
async def get_timestamp_last_summary_email() -> Optional[datetime]:
"""Returns timestamp of the last summary email that has been sent.

Returns
-------
datetime
timestamp of last summary email record in emails table
Returns:
The timestamp of last summary email record in emails table.
"""
query = (
select([emails])
Expand Down
86 changes: 30 additions & 56 deletions rctab/routers/accounting/send_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,12 @@ async def get_sub_email_recipients(
) -> List[str]:
"""Returns the users we should email about this subscription.

Parameters
----------
database : Database
a database to keep a record of a subscription and its users
subscription_id : UUID
a subscription ID
Args:
database : a database to keep a record of a subscription and its users.
subscription_id : a subscription ID.

Returns
-------
List[str]
contains email addresses of the users that should receive the email
Returns:
A string that contains email addresses of the users that should receive the email.
"""
query = get_subscription_details(subscription_id, execute=False)
results = await database.fetch_one(query)
Expand Down Expand Up @@ -99,27 +94,17 @@ def send_with_sendgrid(

Items in the jinja2 template are replaced with those in template_data.

Parameters
----------
subject : str
subject of the email
template_name : str
name of jinja2 template used to render the email
template_data : Dict[str, Any]
data passed to the template
to_list : List[str]
contains the email addresses of the recipients
Args:
subject : The subject of the email.
template_name : The name of jinja2 template used to render the email.
template_data : The data passed to the template.
to_list : A string that contains the email addresses of the recipients.

Returns
-------
int
status code that indicates whether or not email was sent sucessfully

Raises
------
MissingEmailParamsError
raises an error if the api key or the "from" email address
is missing
Returns:
The status code that indicates whether or not email was sent sucessfully

Raises:
MissingEmailParamsError: raises an error if the api key or the "from" email address is missing
"""
# pylint: disable=invalid-name
try:
Expand Down Expand Up @@ -254,12 +239,10 @@ async def send_expiry_looming_emails(
) -> None:
"""If needed, sends emails to say that subscription is nearing its expiry date.

Parameters
----------
database : Database
a database to keep record of subscriptions and of sent emails
subscription_expiry_dates : List[Tuple[UUID, date, SubscriptionState]]
subscription ids and expiry dates of subscriptions nearing expiry
Args:
database: a database to keep record of subscriptions and of sent emails.
subscription_expiry_dates: a list of subscription ids and expiry dates of
subscriptions nearing expiry.
"""
# pylint: disable=use-dict-literal
email_query = sub_time_based_emails()
Expand Down Expand Up @@ -293,12 +276,10 @@ async def send_overbudget_emails(
) -> None:
"""If needed, sends emails to say that subscription is overbudget.

Parameters
----------
database : Database
a database to keep record of subscriptions and of sent emails
overbudget_subs : List[Tuple[UUID, float]]
subscription ids and percentage of budget used for subscriptions that exceeded their budget
Args:
database: a database to keep record of subscriptions and of sent emails.
overbudget_subs: a list of subscription ids and percentage of budget used for
subscriptions that exceeded their budget.
"""
# pylint: disable=use-dict-literal
email_query = sub_usage_emails()
Expand Down Expand Up @@ -328,10 +309,8 @@ async def send_overbudget_emails(
def sub_time_based_emails() -> Select:
"""Builds a query to get the most recent time-based email for each subscription.

Returns
-------
Select
SELECT statement for database query
Returns:
SELECT statement for database query.
"""
most_recent = (
select([func.max_(emails.c.id).label("max_id")])
Expand Down Expand Up @@ -440,10 +419,8 @@ async def check_for_subs_nearing_expiry(database: Database) -> None:
async def check_for_overbudget_subs(database: Database) -> None:
"""Check for subscriptions that should trigger an email as they are overbudget.

Parameters
----------
database : Database
holds a record of the subscription, including budget information
Args:
database: a database that holds a record of the subscription, including budget information.
"""
overbudget_subs = []

Expand Down Expand Up @@ -949,12 +926,9 @@ async def get_approvals_since(
def render_template(template_name: str, template_data: Dict[str, Any]) -> str:
"""Renders html based on provided template and data.

Parameters
----------
template_name : str
name of template
template_data : Dict[str, Any]
data used to render template
Args:
template_name : The name of template.
template_data : The data used to render template

Returns
-------
Expand Down
Loading