Closed karacolada closed 4 years ago
split this Issue, since we should refactor one class at a time
I'm also noticing that a lot of the database functions don't use the elementary functions (add_entry, search_single_entry, ...) but instead write their sql functions entirely by themselves. I think this resulted from those elementary functions not working for all cases at some point (single string as value which needs " ' ", multiple strings which don't, integers, ...), but it would probably be a good idea to refactor this. I'd prefer to keep the specific functions though (like add_game, add_expansion, check_notify, check_user etc) for readability instead of turning every database interaction into a long nested mess of elementary database functions. In turn, these specific functions could all call elementary ones instead of writing their own sql-statement. Hope I explained my thoughts understandably :D
In pull request #71, I noticed that get_playable_entries_by_category only ever gets called with table "games". Since the tables are generated automatically (docker), we could maybe drop "table" as a parameter in order to make this function more usable/readable/understandable/whatever. Things get messy/are going the wrong way if someone tries using this function with another table, just don't allow such errors at all.
database_functions.py
is basically tidied up as of commit 25b3e72fd156ecbf6f61a583aa2d113c2c196785.
It remains to:
Everything in database_functions.py is weirdly nested, and a lot of the functions kind of do the same thing but not entirely and a lot of them are also named similarly. While at it, we might want to have a look at parse_strings.py, too... Need to add documentation and maybe push some functions together/rename them.