Add unit tests and optimize algorithm a bit#785
Merged
geekygirlsarah merged 3 commits intocodethesaurus:mainfrom Dec 27, 2025
Merged
Add unit tests and optimize algorithm a bit#785geekygirlsarah merged 3 commits intocodethesaurus:mainfrom
geekygirlsarah merged 3 commits intocodethesaurus:mainfrom
Conversation
1. Refactored web/models.py * Added helper methods to the Language class to encapsulate "completeness" logic: * is_concept_complete(concept_key): Checks if a concept has code or a comment. * is_category_incomplete(category_concepts_keys): Determines if any concept in a category is missing required data. * has_any_implemented_in_category(category_concepts_keys): Checks if a language implements at least one concept in a category. * Implemented simple in-memory caching for MetaInfo and MetaStructure to avoid redundant file I/O operations when loading JSON metadata and structure files. 2. Optimized web/views.py * Simplified the concepts view by leveraging the new Language model methods, making the logic much more readable and maintainable. * Optimized syntax highlighting by pre-fetching lexers for each language once per request, instead of looking them up for every single concept. * Updated concepts_data, format_code_for_display, and format_comment_for_display to accept pre-fetched lexers, reducing overhead during page rendering. 3. Verification * Verified that all existing unit tests pass. * Ensured that the logic for determining "incomplete" status for languages and categories remains consistent with the original implementation but is now more efficient.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What GitHub issue does this PR apply to?
N/A
What changed and why?
AI bots used in the process of making this PR
Jetbrains Junie to review the site
(If editing website code) Please add screenshots
N/A
Checklist
Any additional comments or things to be aware of while reviewing?