#### Project Information * Repository: https://github.com/holgern/beem * Project Name: Beem * Publisher: @holger80 #### Expected behavior `account.history_reverse(start=start, stop=stop, only_ops=['comment'])` with `start` and `stop` being `datetime` objects should return the all `comment` operations of an account in the given time range. #### Actual behavior `account.history_reverse(start=start, stop=stop, only_ops=['comment'])` may fail with a `TypeError` exception: ``` Traceback (most recent call last): File "account_history_reverse.py", line 10, in <module> for op in a.history_reverse(start=start, stop=stop, only_ops=['comment']): File "/usr/local/lib/python3.6/site-packages/beem/account.py", line 1335, in history_reverse while(op_est + est_diff + batch_size < first and block_date < start): TypeError: '<' not supported between instances of 'str' and 'datetime.datetime' ``` `block_date` is a string in this case and is compared to `start` as a `datetime` object. #### How to reproduce ```python #!/usr/bin/python from beem.account import Account from datetime import datetime, timedelta from beem.utils import addTzInfo a = Account("steemcleaners") start = addTzInfo(datetime.utcnow()) - timedelta(days=1) stop = addTzInfo(datetime.utcnow()) - timedelta(days=7) for op in a.history_reverse(start=start, stop=stop, only_ops=['comment']): print(op) ```  #### Possible fix Suspicion: `block_date` is converted to datetime objects in other places with `formatTimeString()`. This is not the case for the failing location, `h["timestamp"]` is used directly as a string. Possible Fix: ```patch diff --git a/beem/account.py b/beem/account.py index b41cb58..b4ca42f 100644 --- a/beem/account.py +++ b/beem/account.py @@ -1331,13 +1331,13 @@ class Account(BlockchainObject): est_diff = 0 if isinstance(start, (datetime, date, time)): for h in self.get_account_history(op_est, 0): - block_date = h["timestamp"] + block_date = formatTimeString(h["timestamp"]) while(op_est + est_diff + batch_size < first and block_date < start): est_diff += batch_size if op_est + est_diff > first: est_diff = first - op_est for h in self.get_account_history(op_est + est_diff, 0): - block_date = h["timestamp"] + block_date = formatTimeString(h["timestamp"]) else: for h in self.get_account_history(op_est, 0): block_num = h["block"] ``` #### Environment ``` # beempy --version beempy, version 0.19.32 # python --version Python 3.6.5 ``` #### GitHub Account https://github.com/crokkon A Github issue has been created: https://github.com/holgern/beem/issues/13
author | stmdev |
---|---|
permlink | beem-account-historyreverse-may-fail-with-typeerror |
category | utopian-io |
json_metadata | {"tags":["utopian-io","bug-hunting","beem","python","steemdev"],"users":["holger80"],"links":["https://github.com/holgern/beem","https://github.com/crokkon","https://github.com/holgern/beem/issues/13"],"app":"steemit/0.1","format":"markdown","image":["https://cdn.steemitimages.com/DQmVQDt9GVenf71Kdw3khHgdqtmvSFzMJDz43cPaFeP1Z9C/screenshot.png"]} |
created | 2018-05-28 07:18:15 |
last_update | 2018-05-28 08:37:30 |
depth | 0 |
children | 4 |
last_payout | 2018-06-04 07:18:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 45.172 HBD |
curator_payout_value | 14.502 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,969 |
author_reputation | 10,427,398,400,460 |
root_title | "Beem: account.history_reverse() may fail with TypeError" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 58,067,048 |
net_rshares | 14,655,088,439,777 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
dahaz159 | 0 | 41,120,390,674 | 100% | ||
webdeals | 0 | 444,187,347,497 | 100% | ||
yuxi | 0 | 1,965,874,617 | 8% | ||
steemsportsfund | 0 | 92,068,923,270 | 100% | ||
nepd | 0 | 86,103,198,791 | 100% | ||
luna33 | 0 | 75,167,639,493 | 100% | ||
skytrex | 0 | 126,482,800,280 | 100% | ||
suggeelson | 0 | 147,782,812,087 | 100% | ||
rndness222 | 0 | 207,307,040,705 | 100% | ||
zararina | 0 | 43,178,782,807 | 100% | ||
slempase | 0 | 44,151,665,560 | 100% | ||
mygod | 0 | 47,654,649,408 | 100% | ||
shitsignals | 0 | 70,885,650,565 | 100% | ||
crokkon | 0 | 42,105,808,904 | 100% | ||
mawit07 | 0 | 46,409,242,682 | 100% | ||
sniffbiff | 0 | 47,532,125,728 | 100% | ||
arslanahmad | 0 | 77,523,502,828 | 100% | ||
nicholas83 | 0 | 95,692,991,563 | 100% | ||
sevenseals | 0 | 86,435,341,884 | 100% | ||
thekittygirl | 0 | 227,319,241 | 0.25% | ||
utopian-io | 0 | 11,791,520,208,839 | 8% | ||
sailingtohappy | 0 | 131,865,418,601 | 100% | ||
vintherinvest | 0 | 64,887,841,739 | 100% | ||
generouswhale | 0 | 588,288,958 | 100% | ||
kassixo | 0 | 66,200,153,599 | 100% | ||
jutdagut | 0 | 416,349,287 | 100% | ||
tpot | 0 | 62,823,451,329 | 100% | ||
rezawijaya | 0 | 171,114,706 | 50% | ||
r351574nc3 | 0 | 625,320,778 | 1% | ||
steem4all | 0 | 32,745,608,208 | 85% | ||
holger80 | 0 | 127,917,944,231 | 50% | ||
sugardash | 0 | 95,195,847,567 | 100% | ||
salty-mcgriddles | 0 | 770,455,516 | 0.9% | ||
ibez | 0 | 85,840,366 | 20% | ||
yb1337 | 0 | 158,802,168,435 | 100% | ||
hendragunawan | 0 | 204,694,372 | 50% | ||
vampirgarfield | 0 | 132,973,653 | 50% | ||
xglider | 0 | 49,229,627,766 | 100% | ||
robotq | 0 | 69,776,545,530 | 100% | ||
future24.boost | 0 | 135,624,064,489 | 100% | ||
vibes23 | 0 | 41,521,413,224 | 100% |
Thanks for the PR and the issue report. I already merged the [PR](https://github.com/holgern/beem/pull/14) [here](https://github.com/holgern/beem/commit/bd8cf746f7a3287654c9084da6e641bb4838e7ca)
author | holger80 |
---|---|
permlink | re-stmdev-beem-account-historyreverse-may-fail-with-typeerror-20180528t091021375z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"links":["https://github.com/holgern/beem/pull/14","https://github.com/holgern/beem/commit/bd8cf746f7a3287654c9084da6e641bb4838e7ca"],"app":"steemit/0.1"} |
created | 2018-05-28 09:10:21 |
last_update | 2018-05-28 09:10:36 |
depth | 1 |
children | 1 |
last_payout | 2018-06-04 09:10:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.036 HBD |
curator_payout_value | 0.009 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 194 |
author_reputation | 358,857,509,568,825 |
root_title | "Beem: account.history_reverse() may fail with TypeError" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 58,079,494 |
net_rshares | 12,065,159,614 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
crokkon | 0 | 12,065,159,614 | 30% |
.
author | crokkon |
---|---|
permlink | re-holger80-re-stmdev-beem-account-historyreverse-may-fail-with-typeerror-20180528t115217408z |
category | utopian-io |
json_metadata | "{"app": ""}" |
created | 2018-05-28 11:52:18 |
last_update | 2022-09-18 11:51:12 |
depth | 2 |
children | 0 |
last_payout | 2018-06-04 11:52:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1 |
author_reputation | 81,214,366,861,104 |
root_title | "Beem: account.history_reverse() may fail with TypeError" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 58,097,773 |
net_rshares | 0 |
Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category. To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/5/2131113). ---- Need help? Write a ticket on https://support.utopian.io/. Chat with us on [Discord](https://discord.gg/uTyJkNm). [[utopian-moderator]](https://join.utopian.io/)
author | knowledges |
---|---|
permlink | re-stmdev-beem-account-historyreverse-may-fail-with-typeerror-20180528t205324483z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/5/2131113","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"} |
created | 2018-05-28 20:53:27 |
last_update | 2018-05-28 20:53:27 |
depth | 1 |
children | 0 |
last_payout | 2018-06-04 20:53:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.086 HBD |
curator_payout_value | 0.004 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 489 |
author_reputation | 98,021,227,622,369 |
root_title | "Beem: account.history_reverse() may fail with TypeError" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 58,171,019 |
net_rshares | 22,821,237,469 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
knowledges | 0 | 12,864,031,197 | 100% | ||
crokkon | 0 | 9,957,206,272 | 30% |
Hey @stmdev **Thanks for contributing on Utopian**. Congratulations! Your contribution was Staff Picked to receive a maximum vote for the bug-hunting category on Utopian for being of significant value to the project and the open source community. Weβre already looking forward to your next contribution! **Contributing on Utopian** Learn how to contribute on <a href='https://join.utopian.io'>our website</a> or by watching <a href='https://www.youtube.com/watch?v=8S1AtrzYY1Q'>this tutorial</a> on Youtube. **Want to chat? Join us on Discord https://discord.gg/h52nFrV.** <a href='https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
author | utopian-io |
---|---|
permlink | re-beem-account-historyreverse-may-fail-with-typeerror-20180529t072208z |
category | utopian-io |
json_metadata | "{"app": "beem/0.19.29"}" |
created | 2018-05-29 07:22:09 |
last_update | 2018-05-29 07:22:09 |
depth | 1 |
children | 0 |
last_payout | 2018-06-05 07:22:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.029 HBD |
curator_payout_value | 0.007 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 699 |
author_reputation | 152,955,367,999,756 |
root_title | "Beem: account.history_reverse() may fail with TypeError" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 58,234,770 |
net_rshares | 9,546,073,778 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
crokkon | 0 | 9,546,073,778 | 30% |