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

Fix duplicated bots data is saved #13

Merged
merged 5 commits into from
Jun 26, 2023
Merged

Conversation

ngoclong19
Copy link
Contributor

In this PR, I would like to add the following changes:

  • Fix duplicated bots data is saved
  • Update link to ASF bots listing API in README
  • Add ruff, and black in requirements.txt based on recent commits, please leave a comment otherwise
  • Remove folder data from version control, so changes while running scripts do not confuse the working tree.

Steps to reproduce the first issue:

  • Delete data\asf_bots.json
  • Execute python download_bot_listing.py
  • Execute python download_bot_listing.py again
  • Open data\asf_bots.json, there are duplicate Steam IDs.

According to the Python document:
https://docs.python.org/3/library/json.html#json.dumps

Keys in key/value pairs of JSON are always of the type str. When a dictionary is converted into JSON, all the keys of the dictionary are coerced to strings. As a result of this, if a dictionary is converted into JSON and then back into a dictionary, the dictionary may not equal the original one. That is, loads(dumps(x)) != x if x has non-string keys.

In download_bot_listing.py, we have this line user_id = int(user_id_as_str).
This leads to the keys of original_trade_offers and latest_trade_offers have different types, str and int respectively.

@woctezuma woctezuma self-assigned this Jun 26, 2023
@woctezuma woctezuma added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Jun 26, 2023
@woctezuma
Copy link
Owner

Thank you!

@woctezuma woctezuma merged commit 7f2aaaa into woctezuma:master Jun 26, 2023
@woctezuma
Copy link
Owner

woctezuma commented Jun 26, 2023

I just want to say that I could reproduce the issue. 👍 On Google Colab:

Installation:

%cd /content
!git clone https://github.com/woctezuma/steam-trade-finder.git
%cd /content/steam-trade-finder/
%pip install -r requirements.txt

Before the fix:

!git checkout 91552e67d395d77f044805fecaa39ca6245c6d5b
!echo "{}" > data/asf_bots.json
!python download_bot_listing.py
!python download_bot_listing.py

After the fix:

!git checkout 112b62e3964da9a81e8f73d928721999f58d590b 
%rm data/asf_bots.json
!python download_bot_listing.py
!python download_bot_listing.py

Thanks again! 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants