Skip to content

Moves the program post_save signal handler to the module's top level and eliminating the class wrapper#3446

Merged
arkid15r merged 4 commits intoOWASP:mainfrom
PawanMohit16:fix/mentorship-signal-handler
Jan 22, 2026
Merged

Moves the program post_save signal handler to the module's top level and eliminating the class wrapper#3446
arkid15r merged 4 commits intoOWASP:mainfrom
PawanMohit16:fix/mentorship-signal-handler

Conversation

@PawanMohit16
Copy link
Contributor

Proposed change

Resolves #3440

Moves the program post_save signal handler to the module's top level and importing it directly. The class wrapper is eliminated and thereby fixing the SonarCloud python:S5720 code smell.

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

Copilot AI review requested due to automatic review settings January 21, 2026 17:28
@PawanMohit16 PawanMohit16 requested a review from kasya as a code owner January 21, 2026 17:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Summary by CodeRabbit

  • Refactor
    • Streamlined internal code structure for program cache management to improve organization and reduce complexity. Enhanced code maintainability and quality through architectural improvements. All existing functionality and performance are fully preserved with no user-facing changes.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Replaced a class-based Program post-save signal handler with a module-level function and updated the package export to expose the new function; the receiver decorator was moved from the class method to the standalone function.

Changes

Cohort / File(s) Summary
Signal handler refactor
backend/apps/mentorship/signals/program.py
Removed ProgramPostSaveHandler class; added module-level program_post_save_clear_algolia_cache(_sender, instance, **_kwargs) function with @receiver decorator. Signature updated to ignore unused params; logic to log and clear the "programs" Algolia index retained.
Module exports update
backend/apps/mentorship/signals/__init__.py
Replaced exported symbol ProgramPostSaveHandler with program_post_save_clear_algolia_cache to match the refactor.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving the signal handler to module level and removing the class wrapper.
Description check ✅ Passed The description clearly explains the proposed change, references the resolved issue, and details the code smell being fixed.
Linked Issues check ✅ Passed The PR successfully addresses issue #3440 by moving the handler to module level, eliminating the class wrapper and the SonarCloud python:S5720 code smell.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving issue #3440; no out-of-scope modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Program post_save signal handler by removing an unnecessary class wrapper and moving the handler to the module's top level, addressing SonarCloud code smell python:S5720.

Changes:

  • Converted class-based signal handler to a module-level function
  • Updated parameter naming to use underscore prefix for unused parameters (_sender, **_kwargs)
  • Updated imports to reference the function directly instead of the class

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
backend/apps/mentorship/signals/program.py Removed ProgramPostSaveHandler class wrapper and converted signal handler to module-level function with proper parameter naming
backend/apps/mentorship/signals/__init__.py Updated import to reference the function program_post_save_clear_algolia_cache instead of the removed class

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 21, 2026
@sonarqubecloud
Copy link

@arkid15r arkid15r enabled auto-merge January 22, 2026 01:51
Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arkid15r arkid15r added this pull request to the merge queue Jan 22, 2026
Merged via the queue into OWASP:main with commit ed12359 Jan 22, 2026
29 of 30 checks passed
@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (7dc51d7) to head (11b87ef).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@     Coverage Diff      @@
##   main   #3446   +/-   ##
============================
============================

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7dc51d7...11b87ef. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mrkeshav-05
Copy link
Contributor

Hi @PawanMohit16 ,
The solution you implemented for this issue (#3440) seems to be partially incorrect and is causing errors when changing the program status.
While updating the program status, this error occurs:
image

I have implemented a solution in this PR .

@PawanMohit16
Copy link
Contributor Author

Hello @mrkeshav-05 Thanks for pointing it out!
I just went through your PR and I completely missed the GraphQL cache invalidation case on program status updates.
I’ll keep this in mind for similar issues going forward.

@coderabbitai coderabbitai bot mentioned this pull request Jan 22, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename "sender" to "self" or add the missing "self" parameter.

3 participants

Comments