Skip to content

[backend] Add automatic cleanup of old news feed items (#15643)#16018

Open
Antoine-Quintin wants to merge 2 commits into
masterfrom
issue/15643
Open

[backend] Add automatic cleanup of old news feed items (#15643)#16018
Antoine-Quintin wants to merge 2 commits into
masterfrom
issue/15643

Conversation

@Antoine-Quintin
Copy link
Copy Markdown
Contributor

@Antoine-Quintin Antoine-Quintin commented May 15, 2026

Proposed changes

  • New cleanOldNewsFeedItems(context, user, cutoffDate) function in news-feed-domain.ts that deletes locally cached NewsFeedItem entities older than the cutoff. Uses elPaginate + promiseMap with concurrency 5, aligned with the pattern used in loadAndSaveLatestNewsFeed and [backend/frontend] feat(news-feed): mark items as read on list page load (#15934) #15960.
  • Cleanup invocation added in hubRegistrationManager, called after loadAndSaveLatestNewsFeed at each tick (every hour), wrapped in its own try/catch so a cleanup failure doesn't break the manager.
  • New configuration keys hub_registration_manager:news_feed_cleanup_interval_value (default 180) and hub_registration_manager:news_feed_cleanup_interval_unit (default "days"). Pattern reuses the value + unit approach from the existing retentionManager for flexibility (days / hours / minutes / seconds — adjustable without code change).
  • Continues the cleanup of free-string filters started in [backend/frontend] feat(news-feed): mark items as read on list page load (#15934) #15960 by using FilterMode.And and FilterOperator.Lt enums explicitly.
  • 4 new unit tests in newsFeed-test.ts covering filter construction, batch deletion, empty case, and resilience to ALREADY_DELETED_ERROR.

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case (coverage and e2e)
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

@Antoine-Quintin Antoine-Quintin self-assigned this May 15, 2026
@Antoine-Quintin Antoine-Quintin added feature use for describing a new feature to develop xtm-hub feature link with hub team labels May 15, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 78.43137% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.80%. Comparing base (71b54d9) to head (76d4b20).
⚠️ Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
...ncti-graphql/src/manager/hubRegistrationManager.ts 57.50% 17 Missing ⚠️
.../src/modules/xtm/hub/news-feed/news-feed-domain.ts 91.93% 5 Missing ⚠️

❌ Your patch check has failed because the patch coverage (78.43%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #16018      +/-   ##
==========================================
+ Coverage   34.49%   35.80%   +1.31%     
==========================================
  Files        3254     3278      +24     
  Lines      220156   227505    +7349     
  Branches    40877    43750    +2873     
==========================================
+ Hits        75935    81468    +5533     
- Misses     144221   146037    +1816     
Flag Coverage Δ
opencti-client-python 46.36% <ø> (ø)
opencti-front 4.06% <ø> (+0.64%) ⬆️
opencti-graphql 73.15% <78.43%> (+1.83%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Antoine-Quintin Antoine-Quintin force-pushed the issue/15643 branch 2 times, most recently from ae61351 to 3e52ca3 Compare May 15, 2026 13:46
@Antoine-Quintin Antoine-Quintin marked this pull request as ready for review May 15, 2026 14:00
Comment thread opencti-platform/opencti-graphql/src/manager/hubRegistrationManager.ts Outdated
Comment thread opencti-platform/opencti-graphql/tests/01-unit/domain/newsFeed-test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature use for describing a new feature to develop xtm-hub feature link with hub team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup old newsfeed (older than 6 months)

2 participants