Skip to content

FEAT/Calculate business days elapsed based on two inputs#31

Open
cris-seaton wants to merge 12 commits intomasterfrom
feat/business_day_udf
Open

FEAT/Calculate business days elapsed based on two inputs#31
cris-seaton wants to merge 12 commits intomasterfrom
feat/business_day_udf

Conversation

@cris-seaton
Copy link

addressing the click-up task: https://app.clickup.com/t/863gevf8v

@cris-seaton
Copy link
Author

remaining: documentation for create_udf_business_hours macro.

Copy link

@alex-m01 alex-m01 left a comment

Choose a reason for hiding this comment

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

hi @cris-seaton ! I've left a few comments and suggestions. If you have any questions, please let me know.

@cris-seaton cris-seaton changed the title Calculate business days elapsed based on two inputs FEAT/Calculate business days elapsed based on two inputs May 29, 2023
@cris-seaton cris-seaton requested a review from alex-m01 May 29, 2023 18:49
# weekend, therefore return 0 via max(0,business_hours).

while start_datetime.date() in holiday_list or start_datetime.weekday() in [5,6]:
start_datetime = start_datetime.replace(hour=opening_hour,minute=0,second=0) + timedelta(days=1)
Copy link
Author

Choose a reason for hiding this comment

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

cannot utilize L31 or L32 here because these are different context, this while loop turns start_datetime in first_day_OPENED (i.e. if start occurs on holiday or weekend, iterate forward to 9am first available non-holiday or weekday.

# When start_datetime is iterated beyond end_datetime, this indicates entirety of hours occuring during holidays or
# weekend, therefore return 0 via max(0,business_hours).

while start_datetime.date() in holiday_list or start_datetime.weekday() in [5,6]:
Copy link
Author

Choose a reason for hiding this comment

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

After your review, going to talk to Peter about practicality on omitting weekdays. we could make it a boolean tag in the call, (i.e.

udf_business_hours(start_datetime, end_datetime, country, omit_weekends[Yes|No]) but it will complicate the code with more conditional if statements for the while loop L48 and the if statement L57

@cris-seaton
Copy link
Author

@alex-m01 set for re-review.

Copy link
Contributor

@JFrackson JFrackson left a comment

Choose a reason for hiding this comment

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

This looks great. Is there a standard that you've worked on to help test these UDFs? When they're wrapped up in SQL I can imagine it's more challenging. Is there a simple way of defining these python functions in Python files that can then be tested with pytest?

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.

3 participants