site
site copied to clipboard
Linked otnames.
We'd like to be able to link otnames together, so that they always appear at the same time. This issue needs to be handled at the same time as the problem is solved on the bot side, because both will rely on each other for proper testing. Bot issue can be found at https://github.com/python-discord/bot/issues/658.
For example, we may want the following names to always appear together:
#ot0-what-is-your-name?
#ot1-what-is-your-quest?
#ot2-what-is-your-favorite-color?
- [ ] Create a new field in the off topic channel name model called
linked_names. This field should be an ArrayField that can have up to 3 CharFields. This is where we will put all the names that are linked, in the correct order. - [ ] Create a migration. The new field should be an empty array by default.
- [ ] Create new views in the off topic names viewset. We will probably need one method for linking names together, and one for unlinking them. I leave this step only vaguely defined on purpose, because it may be useful to have some flexibility here if you run into design problems.
The basic idea is that, whenever we link names together, we will add all the names to all the otnames objects in this linked_names field. That way, no matter which one you get, you will have all the information you need without making additional queries.
Il wouldn’t be smarter to use 2 ForeignKeys inside the linked_name field? I think it would be easier to just create 3 OffTopicName and link them together, so when one the name is chosen, we can just resolve the 2 other name. It would probably be easier for future OT name editing or deletion too.
Yeah, it might be better to use foreignkeys. If we edit one of these off-topic names, we would want the new name to be carried into all the linked_name fields. We should probably think about what happens if we delete one of them too. Will having foreignkeys in the array ensure that they disappear from the array?
We could make them be null value or just make them disappear when deleted by changing the on_delete setting of the field, and make sure the view return a random OT name if one linked_name is null or empty.
well, it's something we'll probably need to play around with. But I'd be open to a solution that involved ForeignKeys as long as it works and solves all our use cases and edge cases.
This is a great idea, Lemon. But should we extend the base off topic name model? I think creating a new "linked otnames" table with three foreign key fields may be more intuitive, as we don't duplicate the information then.
Closing as the bot issue https://github.com/python-discord/bot/issues/658 was closed.
Thanks @Xithrius