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

clean pending update based on Timedelta or datetime#1987

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

Closed

Conversation

ikkemaniac
Copy link
Contributor

@ikkemaniacikkemaniac commentedJun 9, 2020
edited
Loading

Follow-up of#1978

Add option to pass atimedelta ordatetime as varclean to.start_polling() or.start_webhook().
Updates with a timestamp beforenow - timedelta will be ignored.
Updates beforedatetime will be ignored.

I'm not familiar with the test-module to write these from scratch as this is not a 'direct' function to test. Can put in some time if y'all can point me to similar examples?

Maybe needs some cleanup but need the gh test bot results for that.

harshil21 reacted with thumbs up emoji
@ikkemaniacikkemaniac changed the titleTimedeltaclean pending update based on TimedeltaJun 9, 2020
@Bibo-Joshi
Copy link
Member

Hi. Thanks for the PR. TBH, I haven't looked in too much detail, yet.

Regarding tests: I'm a bit surprised that we don't test clean at all. But If I see correctly, it should be enough to mockBot.get_updates to return a custom list of updates. You can addmonkeypatch to the args of the test function and usemonkeypatch.setattr(bot, 'get_updates', 'some_func_to_call_instead_of_get_updates') for that. We usemonkeypatch a lot in the tests, so you should be able to find examples :)

A few other things I noticed:

  • It would be desirable to also allowdatetime input forclean (naive datetimes should be interpreted as UTC)
  • AfterAdd tz kwarg to from_timestamp() #1621message.date is already timezone aware, so you shouldn't have to replace the timezone
  • In fact, we'll need to make sure that different timezones are handled correctly, especially fordatetime. We have a custom fixturetimezone for that, that you can use as arg for the test functions

If you have more questions, please don't hesitate and ask :)

@ikkemaniac
Copy link
ContributorAuthor

Ok, I'll look into it. Is the use of**kwargs like this accepted?

@Bibo-Joshi
Copy link
Member

Ok, I'll look into it. Is the use of**kwargs like this accepted?

Mh … I guess it would be cleaner to either add an explicit argumentaction_db_kwargs or usefunctools.partial to pass thetimedelta/datetime tobootstrap_clean_time…

@Bibo-JoshiBibo-Joshi added the 📋 pending-replywork status: pending-reply labelJun 10, 2020
ikkemaniac added2 commitsJune 10, 2020 22:00
…erify timezone is set, fix it if not. Throw ValueError is timedelta < 1 sec or datetime not < '1 sec' from now.Still has a lot of debugging stuff in there.
@ikkemaniac
Copy link
ContributorAuthor

A few other things I noticed:

* It would be desirable to also allow `datetime` input for `clean` (naive datetimes should be interpreted as UTC)* After #1621 `message.date` is already timezone aware, so you shouldn't have to replace the timezone* In fact, we'll need to make sure that different timezones are handled correctly, especially for `datetime`. We have a custom fixture `timezone` for that, that you can use as arg for the test functions

Done. Freaking hate handling datetimes....

Ok, I'll look into it. Is the use of**kwargs like this accepted?

Mh … I guess it would be cleaner to either add an explicit argumentaction_db_kwargs or usefunctools.partial to pass thetimedelta/datetime tobootstrap_clean_time…

Done, used functools.partial. Thx btw, learned something new today :)

@ikkemaniac
Copy link
ContributorAuthor

ikkemaniac commentedJun 10, 2020
edited
Loading

note to self
TODO:

  • if code accepted copy code to start_webhook
  • Testing.py
  • cleanup

@Bibo-JoshiBibo-Joshi added 📋 pending-reviewwork status: pending-review and removed 📋 pending-replywork status: pending-reply labelsJun 10, 2020
@ikkemaniac
Copy link
ContributorAuthor

ikkemaniac commentedJun 10, 2020
edited
Loading

I keep running into issues w/ pytest to get it running properly (keep kettingImportWarning. Do y'all have a working docker-ptb-dev available, amd64-*nix?

@Poolitzer
Copy link
Member

Poolitzer commentedJun 11, 2020
edited
Loading

No but we have dev requirements did you install them?

ikkemaniac added26 commitsJune 17, 2020 00:03
This reverts commitafe7b24.
This reverts commitd3479c0.
This reverts commit9f5a8ce.
@ikkemaniac
Copy link
ContributorAuthor

Basically, I fear that we might construct a very specific solution for a complex use case, which might lead to it either being not very useful and/or people wanting to add more and more options to it in order to adapt to their wishes.
But maybe you see things differently and/or have a clever solution for the things a mentioned. Anyway, I'd like to hear what you think :)

I haven't been able to come up with a all encompassing solution ... i guess you are right, it's too specific and not worth the effort.

I'll close this PR.

@Bibo-Joshi
Copy link
Member

Okay. Still, thanks for taking the time and making the effort. It's always appreciated :)

@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsAug 17, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@Bibo-JoshiBibo-JoshiBibo-Joshi requested changes

Assignees
No one assigned
Labels
📋 pending-reviewwork status: pending-review
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@ikkemaniac@Bibo-Joshi@Poolitzer

[8]ページ先頭

©2009-2025 Movatter.jp