Skip to content

Conversation

@geekygirlsarah
Copy link
Member

What GitHub issue does this PR apply to?

N/A

What changed and why?

  • Added additional unit tests to ensure more code coverage
  • Optimize some of the views to fetch lexers once (instead of multiple times), make language/concept code more readable
  • Added helper methods to Language class and cache MetaInfo and MetaStructure classes to reduce file IO

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

  • I claimed any associated issue(s) and they are not someone else's
  • I have looked at documentation to ensure I made any revisions correctly
  • I tested my changes locally to ensure they work
  • For language files, I have validated the edited files are valid JSON and data shows up correctly
  • For website code edits, I have added or edited any appropriate unit tests for my changes
  • If I used artificial intelligence (AI), I have reviewed the suggested changes and ensured they work correctly

Any additional comments or things to be aware of while reviewing?

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.
@geekygirlsarah geekygirlsarah self-assigned this Dec 27, 2025
@geekygirlsarah geekygirlsarah merged commit abf8d78 into codethesaurus:main Dec 27, 2025
4 of 5 checks passed
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.

1 participant