uchicago-cs / chigame

BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Refactor BGG and XML parsing code into a `games/utils folder` #393

Open willcravitz opened 9 months ago

willcravitz commented 9 months ago

Some new and important code related to fetching information from BoardGameGeek is in wiki pages:

Creating Game Fixtures Creating Category and Mechanic Fixtures

Initially, we put these scripts here because there was not a good place for them in the codebase. However, it has become clear that they should be integrated into the codebase because: 1) As changes are made to the game/category/mechanic models, these fixtures need to be regenerated. 2) Not having certains functions in the codebase has led us to violate DRY. As an example, the code to autofill games in the create games page and the code to create category and mechanic fixtures is missing the XML parsing functionality that was implemented here.

Proposed next steps:

  1. Create a games/utils folder with a file for BGG API functions and separate script files to regenerate fixtures.
  2. The most up to date BGG API code is a combination of the Creating Game Fixtures and the autofilling code in src/chigame/games/views.py. The code in these places should be combined and put into the games/util folder.
  3. The code to cleanly parse XML code should be added to the code for autofilling game creation and to the code for creating category and mechanic fixtures.

Functions to look at:

# src/chigame/games/views.py
def bgg_search_by_name(request):
def bgg_search_by_id(request):
def bgg_get_game_details(bgg_id):