Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Business info#4183

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged

Conversation

aelkheir
Copy link
Member

@aelkheiraelkheir commentedApr 1, 2024
edited
Loading

Partiallycloses#4179

Information about Business Accounts [Taken by@aelkheir]

Check-list for PRs

  • Added.. versionadded:: NEXT.VERSION,.. versionchanged:: NEXT.VERSION or.. deprecated:: NEXT.VERSION to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
  • Created new or adapted existing unit tests
  • Documented code changes according to theCSI standard <https://standards.mousepawmedia.com/en/stable/csi.html>__
  • Added myself alphabetically toAUTHORS.rst (optional)
  • Added new classes & modules to the docs and all suitable__all__ s
  • Checked theStability Policy <https://docs.python-telegram-bot.org/stability_policy.html>_ in case of deprecations or changes to documented behavior

If the PR contains API changes (otherwise, you can ignore this passage)

  • New classes:
    • Addedself._id_attrs and corresponding documentation
    • __init__ acceptsapi_kwargs as kw-only
  • If relevant:
    • Added or updated documentation for the changed class(es) and/or method(s)

@aelkheiraelkheir marked this pull request as draftApril 1, 2024 16:10
@aelkheiraelkheir changed the titleBusiness info[WIP] Business infoApr 1, 2024
@harshil21harshil21 mentioned this pull requestApr 2, 2024
27 tasks
@aelkheiraelkheir changed the title[WIP] Business infoBusiness infoApr 2, 2024
@aelkheiraelkheir marked this pull request as ready for reviewApril 2, 2024 15:21
@aelkheir
Copy link
MemberAuthor

Ready for review.

Copy link
Member

@harshil21harshil21 left a comment

Choose a reason for hiding this comment

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

Pretty much perfect overall. Just left some comments mostly regarding naming/doc inconsistencies.

Also I just realized that you may need TG Premium to test opening/closing_minute related review comment so you can just ignore that if you don't have premium and i'll handle that later.

@harshil21harshil21 added the ⚙️ bot-apiaffected functionality: bot-api labelApr 3, 2024
@aelkheir
Copy link
MemberAuthor

Thanks for the review!

With regard toopening/closing_hours utilzing pythondatetime, A hurdle would be thatdatetime.datetime anddatetime.date typically expect a specific day in month while a business having an opening in (e.g.) Monday at 9 am would mean any Monday regardless of the month/week.
I also thoughtdatetime.time, which can be an improvement except that we also lose context of which day [Sat, Mon, ...] this opening/closing belongs to.

Finally, we could make a utilityBusinessOpeningHoursInterval.parse_hour that works like this

(day,hour,minute)=parse_hour(opening/closing_hours)# where day in [0, 1, .., 6]# hour in [0, 1, .., 24],# minute in [0, 1, .., 60]

But also users can calculate it themselves, since it's simple math operations.
what do you think?

@harshil21
Copy link
Member

harshil21 commentedApr 4, 2024
edited
Loading

I just tested what values are returned by the API and it's clear that those times are representing the minute of the week. Here's the results:

Monday - 00:00 - 01:05: BusinessOpeningHoursInterval(closing_minute=65, opening_minute=0)Monday - 08:00 - 20:00: BusinessOpeningHoursInterval(closing_minute=1200, opening_minute=480)Tuesday - 24 hours: BusinessOpeningHoursInterval(closing_minute=2879, opening_minute=1440)Thursday - 11:30 - 20:00: BusinessOpeningHoursInterval(closing_minute=5520, opening_minute=5010)Sunday - 00:00 - 23:58: BusinessOpeningHoursInterval(closing_minute=10078, opening_minute=8640)

I'll update the doc to further explain how those numbers are achieved.


Now the utility function - I like your idea but we can split it into two different properties -opening_time andclosing_time which do return that tuple of int's representing day, hour, and minute. This means that the user won't need to supply any input parameters.

We can also go one step further and overrideBusinessOpeningHoursInterval.__str__ and provide a friendly representation which returns e.g.Monday: 8am - 8pm. Thus a user can easily iterate overBusinessOpeningHours.opening_hours and justprint() it to see the values.

Another idea - (this may be a little out of scope) - We can have another function

BusinessOpeningHours.convert_to_timezone(timezone:datetime.tzinfo)->BusinessOpeningHoursInterval

Advantage is that its easier to schedule jobs and reduces potential errors.

cc@Bibo-Joshi

@harshil21
Copy link
Member

@aelkheir so@Bibo-Joshi and I discussed internally and decided to not pursueBusinessOpeningHoursInterval.__str__. As for the other two functions, you may complete them in this PR or choose to do it in another PR as it's not a priority. Let me know if you want to do them now, otherwise this PR is good to be merged.

@aelkheir
Copy link
MemberAuthor

not pursue BusinessOpeningHoursInterval.str.

Funnily enough i was just here to say that I don't know of a universal time representation that may fit all users, so we could let them use thetuple of ints and produce a representation to their liking.

I'll do it here and get it over with. But not untill tomorrow night hopefully :).

harshil21 reacted with thumbs up emoji

@aelkheir
Copy link
MemberAuthor

About the functionconvert_to_timezone, It turned out to be a but tricker, specifically becauseBusinessOpeningHoursInterval.{opening/closing}_minute could not not be represented as regular datetime/date/time.

A possibility i thought about was to get hours offset fromBusinessOpeningHour.time_zone_name toconvert_to_timezone.timezone and then do

BusinessOpeningHoursInterval(opening_minute=opening_minute+offset*60,closing_minute=closing_minute+offset*60)

with special handling to keep the minutes in the range0 - 10080

But this will require us to use pytz (?), and I see it's optional.
any thoughts@harshil21

Copy link
Member

@Bibo-JoshiBibo-Joshi left a comment

Choose a reason for hiding this comment

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

Nice PR, thank you very much!

Regardingconvert_to_timezone & other auxiliary functionality: representing an offseted-time in form ofBusinessOpeningHoursInterval doesn't make much sense to me, tbh.

What I could think of is a methodBOH.get_opening_hours_for_day(dtm.date, tzinfo=None) -> tuple[tuple[dtm.datetime, dtm.datetime], …]. I.e. you provide a specific day and optionally a timezone and get as return value a sequence of the opening intervals for that day in the desired timezone. Making the user provide a timezone would also lift the requirement on our side to build the tzinfo object. We'd only have to deal with the case where the user does not pass a timezone and we'd fall back totime_zone_name. Untilzoneinfo becomes usable for us (once we drop py3.8 I would personally just leave the datetime tz-naive …

Another thought that I had isBOH.is_open(dtm.datetime) -> bool, i.e. a method that would allow you to check if the business is open at that specified time. However I see that tz-dealing is more difficult again here, if we can't build a tzinfo object fromtime_zone_name, which brings me to believe that this should also wait until we drop py3.8

Since this functionality is very new and this is only the initial implementation on our end, I would not like to add additional dependencies for these, still rather minor, convencience methods. Once could ofc raise RuntimeError if pytz is not availbale, but that also seems like rather much effort for little gain …

@harshil21
Copy link
Member

Okay, I'm fine with waiting until we drop py 3.8 to implement these functions.

@aelkheir
Copy link
MemberAuthor

October (python 3.8 end of life) is not so far away. By then pytz could be droped entirely in favor of zoneinfo.

Thanks very much team for the opportunity <3

harshil21 reacted with thumbs up emoji

@Poolitzer
Copy link
Member

@aelkheir Thanks for the contribution!

aelkheir reacted with heart emoji

@Bibo-JoshiBibo-Joshi merged commitbb9bdb4 intopython-telegram-bot:api-7.2Apr 6, 2024
@aelkheiraelkheir deleted the business-info branchApril 6, 2024 21:30
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 14, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@Bibo-JoshiBibo-JoshiBibo-Joshi left review comments

@harshil21harshil21harshil21 approved these changes

Assignees
No one assigned
Labels
⚙️ bot-apiaffected functionality: bot-api
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@aelkheir@harshil21@Poolitzer@Bibo-Joshi

[8]ページ先頭

©2009-2025 Movatter.jp