-
Notifications
You must be signed in to change notification settings - Fork 32
Add group origin universe overview page with links to all #699
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
base: beta
Are you sure you want to change the base?
Add group origin universe overview page with links to all #699
Conversation
Summary of ChangesHello @adam-knights, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the platform's data browsing capabilities by introducing dedicated overview pages for 'Group Origin Universe', building upon similar functionality previously implemented for characters. It addresses a critical bug in group relation filtering, ensuring that group generalisations are correctly identified and displayed. The changes integrate universe-specific filtering into numerous existing views and tables, providing a more consistent and detailed user experience when exploring groups within the context of their originating universes. Additionally, minor UI improvements and navigation links have been added to improve overall usability and consistency. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces group origin universe pages, mirroring existing functionality for characters. It also includes several important bug fixes and refactorings, such as correcting a relation ID for group generalizations, fixing incorrect headings, and removing stray UI text. The code is cleaner and more reusable in several places. I've identified a few critical issues related to incorrect super() calls that could lead to bugs, and some potential race conditions with .get() that should be addressed. There are also a couple of minor bugs and opportunities for performance improvement. Overall, a great set of changes that significantly enhance functionality.
| self.group = kwargs.pop('group') | ||
| self.universe_id = kwargs.pop('universe_id', None) | ||
| self.resolve_name = 'group' | ||
| super(CharacterFeatureTable, self).__init__(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This super() call is incorrect. GroupFeatureTable inherits from CharacterFeatureTable, so the super() call should refer to GroupFeatureTable to correctly call the parent's __init__ method. The current implementation will skip CharacterFeatureTable.__init__ and call the __init__ of its parent (FeatureSearchTable), which is likely not the intended behavior and can lead to bugs. The correct Python 3 syntax would be super().__init__(*args, **kwargs).
| super(CharacterFeatureTable, self).__init__(*args, **kwargs) | |
| super().__init__(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is existing code and i believe intended
| self.group = kwargs.pop('group') | ||
| self.universe_id = kwargs.pop('universe_id', None) | ||
| self.resolve_name = 'group' | ||
| super(SeriesTable, self).__init__(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This super() call is incorrect. GroupSeriesTable inherits from CharacterSeriesTable, but this call skips CharacterSeriesTable.__init__ and its parent's __init__, directly calling a method from SeriesTable's MRO. This is a bug and can cause incorrect initialization. The correct Python 3 syntax would be super().__init__(*args, **kwargs).
| super(SeriesTable, self).__init__(*args, **kwargs) | |
| super(CharacterSeriesTable, self).__init__(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is existing code and i believe intended
| def active_universe_appearances(self): | ||
| from .story import Story | ||
| if self.universe and self.active_generalisations().exists(): | ||
| group = self.active_generalisations().get().from_group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of .get() here is risky as active_generalisations() could potentially return more than one object, which would raise a MultipleObjectsReturned exception. To make the code more robust, consider using .first() and checking if an object was returned. This will prevent unexpected server errors if the data ever allows for multiple generalizations.
| group = self.active_generalisations().get().from_group | |
| group = self.active_generalisations().first().from_group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the character version that already exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want server errors if the data is wrong.
| appearances = Story.objects.filter( | ||
| appearing_groups__group_name__group=self, | ||
| appearing_groups__deleted=False, | ||
| appearing_groups__universe_id=origin_universe, | ||
| deleted=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query is missing a filter for appearing_groups__deleted=False. Other similar queries in this file include this filter to exclude deleted story-group relationships. Without it, you might be including data from deleted appearances.
appearances = Story.objects.filter(
appearing_groups__group_name__group=self,
appearing_groups__universe_id=origin_universe,
appearing_groups__deleted=False,
deleted=False)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7497f30
| filter_group = group.active_generalisations().get()\ | ||
| .from_group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of .get() here is risky as active_generalisations() could potentially return more than one object, which would raise a MultipleObjectsReturned exception. To make the code more robust, consider using .first(). This will prevent unexpected server errors if the data ever allows for multiple generalizations.
| filter_group = group.active_generalisations().get()\ | |
| .from_group | |
| filter_group = group.active_generalisations().first()\ | |
| .from_group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches characters.
| break | ||
| if not found: | ||
| # more a GroupNameDetail.DoesNotExist exception here ? | ||
| raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-raising the MultipleObjectsReturned exception here will result in a 500 server error, which is not user-friendly. The developer comment suggests this might not be the best behavior. Consider handling this case more gracefully by rendering an error page to the user, similar to how other errors are handled in this view (e.g., the "Name does not exist at group generalization" error).
return render(request, 'indexer/error.html',
{'error_text':
'Could not find a unique name match for '
'the group generalization.'})There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code now matches the character equivalent, we would change together if we want to.
apps/gcd/views/details.py
Outdated
| stories = Story.objects.filter(**query).distinct()\ | ||
| .select_related('issue__series__publisher') | ||
|
|
||
| heading = 'Sequences for Group %s' % (group) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7497f30
| def __init__(self, *args, **kwargs): | ||
| self.universe = kwargs.pop('universe') | ||
| kwargs['group'] = True | ||
| super(UniverseGroupTable, self).__init__(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the existing UniverseCharacterTable for consistency.
apps/gcd/views/details.py
Outdated
| 'with group %s', | ||
| (group,)) | ||
|
|
||
| issues = issues.filter(**query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query might return duplicate Issue objects if a creator worked on multiple stories within the same issue that match the query. Consider adding .distinct() to the end of the filter to ensure each issue appears only once in the results, similar to how it's handled in other parts of the code (e.g., in checklist_by_id).
| issues = issues.filter(**query) | |
| issues = issues.filter(**query).distinct() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7497f30
apps/gcd/views/details.py
Outdated
| if issues: | ||
| selected_issue = issues[randint(0, issues.count()-1)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7497f30 - also did the same to the origin character equivalent from last time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think issues,count() is cached, so
if issues.count():
would be fine as well
Following on from #696 we also implement the group origin universe pages in the same way. Code reuse and my styling should be much more in keeping first time this time :). Tested lots locally with normal group, origin with group and group with universe attached.
There was also an existing bug where active_generalisations was not working on groups, the relation id was using 6 like characters, but it needs to be 5 on groups. This probably means its not used much / we don't have many bottom level groups, but good to have it working consistently like characters in any case, so all the views now use active_generalisations too to support both ways to view. As an example if you goto https://www.comics.org/group/4/, fourth from the bottom there should be a link to the bottom level group for MC2 but its not displayed, and then with the fix locally:
There was also a couple heading texts I'd got wrong on the character implementation where 'with origin' appeared before the wrong %s, those are fixed too.
I noticed a random 'external links' in the middle of the group page, i think not intentional, so removed it, but can adjust if needed:
Finally, because all the code is now there, i added the 'Groups from this universe' link to the universe page and supporting table etc: