Skip to content

Update OpenSearch upon item removal from Moderation Dashboard#3366

Open
michaelcanova wants to merge 8 commits intomainfrom
opensearch_clear_on_remove
Open

Update OpenSearch upon item removal from Moderation Dashboard#3366
michaelcanova wants to merge 8 commits intomainfrom
opensearch_clear_on_remove

Conversation

@michaelcanova
Copy link
Copy Markdown
Contributor

Overview

This PR adds functionality to clear OpenSearch when items are removed from the Moderation Dashboard
1. If an individual item is removed (Remove button), it will remove that item
2. If a user is removed (Remove + Suspend) all items pertaining to that user will be removed

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.43%. Comparing base (24c9816) to head (4386921).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3366      +/-   ##
==========================================
+ Coverage   79.40%   79.43%   +0.02%     
==========================================
  Files         638      639       +1     
  Lines       37081    37114      +33     
==========================================
+ Hits        29446    29483      +37     
+ Misses       7635     7631       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@michaelcanova michaelcanova marked this pull request as ready for review April 24, 2026 19:55
@michaelcanova michaelcanova requested a review from a team as a code owner April 24, 2026 19:55
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026


@patch("discussion.views.remove_from_search_index")
def test_resolves_unified_document_to_inner_doc(self, mock_remove):
from discussion.views import censor
Copy link
Copy Markdown
Member

@gzurowski gzurowski May 5, 2026

Choose a reason for hiding this comment

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

Push to top

class TestCensorUnifiedDocument(TestCase):

@patch("discussion.views.remove_from_search_index")
def test_resolves_unified_document_to_inner_doc(self, mock_remove):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Add AAA markers

Comment thread src/search/tasks.py Outdated
Comment on lines +21 to +24
sync_search_index(Paper.objects.filter(is_removed=True))
sync_search_index(
ResearchhubPost.objects.filter(unified_document__is_removed=True)
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This queryset will grow large over time which will cause large amounts of registry updates redundantly.

Copy link
Copy Markdown
Member

@gzurowski gzurowski left a comment

Choose a reason for hiding this comment

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

The change couples discussion, hub, paper, RH document with the search app that already depends on those, creating a dependency circle between these modules. I would prefer a solution that doesn't introduce this form of coupling.

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.

2 participants