Skip to content

Comments

Issue 64 investigate auto filling games and contributors from itch io#127

Open
Games4Doritos wants to merge 27 commits intomainfrom
issue-64-Investigate_auto_filling_games_and_contributors_from_itch_io
Open

Issue 64 investigate auto filling games and contributors from itch io#127
Games4Doritos wants to merge 27 commits intomainfrom
issue-64-Investigate_auto_filling_games_and_contributors_from_itch_io

Conversation

@Games4Doritos
Copy link
Collaborator

@Games4Doritos Games4Doritos commented Feb 21, 2026

Change Summary

Added 2 new fields to the Event model, a positive big int called jamID and a JSONfield called games which represents a list of Game object integer id's. These fields allow for Game Jams to be a sort of variant of the Event model. If a jamID is specified, when the Event object is saved, a script will run to automatically create Game and Game Contributor objects from the Jam:

  • Using the Python Requests library (a new dependancy put into the relevant files), a http GET request will be made to the url, https://itch.io/jam/{jamID}/results.json, which will return json content that lists all the Games submitted to the Jam and their details
  • For each game listed, a Game object will hopefully be made from all the relevant details, such as the event field being set to this Event object, or the game's cover image being uploaded to the database and added to the thumbnail field
  • For each contributor listed under the game, the SocialMedia objects will be checked to see if any of the itch users are registered from the username, and so will link a SocialMedia object's member to the game by creating a GameContributor object if found
  • Each game's unique integer id will be appended to the Event object's games field
image

Change Form

  • The pull request title has an issue number
  • The change works by "Smoke testing" or quick testing
  • The change has tests
  • The change has documentation

Other Information

Related issue

- Added Jam Model with three attributes:  a big positive integer id, a name, and list of integer Game object id's called games
Explanation of my approach to the problem:
The easy way to I think to automatically fill games is to simply override the Jam model's save() function, so the populating script will automatically run every time a Jam object is saved. This function will send a http GET request to a specific URL, using the object's id as a parameter, which will hopefully return json data that lists all the games submitted to the specific jam. A Game object will be created for each listed game (they contain enough information for a detailed object), and then each of those new object's id's in the database will be appended to the Jam object's 'games' list. This may be a bit naive so we will definitely discuss
- Registered the Jam model in admin.py with appropriate attributes
- Added a new dependency: the python Requests library (https://requests.readthedocs.io/en/latest/), along with it's own dependencies. This is simply needed to make the http GET request in the save() function. We can look at alternatives as well, I think this is just the common python one.
-Removed Jam model and migration file
- Added the id and games attributes from the Jam model as optional attributes to the event model instead. The same save() function in the Jam model has been adjusted and added to the event model, where both fields will be forced to be blank if a valid jam id isn't provided.
- Removed Jam model configuration from admin.py
- Removed newest migration's dependency on the deleted Jam migration
- Added more exception handling for the  save() function in the Event model, now handling the http GET request as well
- Made a helper function called jamFail() to reduce redundancy
- Modified how the thumbnails for Game objects are initialised in the save() function, such that each game's image is directly downloaded into the backend by making a GET request to the "cover_url" attribute
- Changed help_text parameter for jamID to be more understandable
- Updated save() function for Event model such that every Game object created for a Jam has it's event attribute set to the corresponding Event object being saved
- Updated id of the my migration to the Event model unique to this branch, so it is most recent and thus no merge migration is required
- Added logic in the save() function in the Event model, where it will check if the username of each of the contributors for a game is registered in a current SocialMedia object, where it will then create a GameContributor object using the Member object linked to the SocialMedia object
- Corrected spelling for some model attributes
- Made minor changes to models.py to appease flake8
- Renamed the migration that creates the jamID and games fields for the Event model to 0015 as the latest, with the latest merged migration as its dependency. This is to avoid an unnecessary migration merge.
- Added a failsafe for if a Jam's json does have a results key, but the list of results is empty
- Added exception handling for downloading and saving a game's cover image
- Appeased flake8
- Moved the super().save() function to the top of the Event model save() function, so the Event object itself is saved before the games are autofilled. This was to prevent an error where a created Game linked the Event object as a foreign key before it was saved.
Added super().save() back to every return statement in the Event model's save() function, so the object will be saved at the start and also saved at the end of the save() function so the games and jamID attributes are fully updated
- Switched all instances of the save() function to asave() (asynchronous save) instead. I think this solves some UNIQUE constraint integrity errors from testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate auto filling games and contributors from itch.io

1 participant