Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race condition bug deleting categories #40

Merged
merged 8 commits into from
Jul 31, 2024

Conversation

cardmagic
Copy link
Owner

@cardmagic cardmagic commented Jul 31, 2024

Changes Overview

Thank you @dpetruha for catching this bug!

These changes primarily focus on updating the Ruby gem version, modifying the CI workflow, and improving the Bayesian classifier functionality. The main modifications include:

  1. Updating the Ruby versions tested in the CI workflow.
  2. Incrementing the gem version.
  3. Modifying the remove_category method in the Bayesian classifier.
  4. Adding new tests for the remove_category functionality.

Reason for Changes

The changes aim to update the gem's compatibility, improve its version tracking, and enhance the robustness of the Bayesian classifier's category removal feature.

Detailed Description

  1. CI Workflow Update - The .github/workflows/ruby.yml file has been modified to test fewer Ruby versions, now only including '2.7' and 'head'. This change likely aims to focus testing on the oldest supported version and the latest development version.

  2. Gem Version Update - The gem version has been incremented from 1.4.1 to 1.4.2 in the classifier.gemspec file. This indicates a minor update or bug fix release.

  3. Bayesian Classifier Improvement - The remove_category method in lib/classifier/bayes.rb has been modified to update the @total_words count before deleting the category data. This ensures that the total word count is accurately maintained even when categories are removed.

  4. New Tests - Three new tests have been added to test/bayes/bayesian_test.rb to verify the correct functionality of the remove_category method:

    • A test to ensure that category data is properly removed.
    • A test to confirm that the total word count is updated correctly.
    • A test to check that an error is raised when attempting to remove a non-existent category.

- Move total word count reduction before category deletion
- Ensure accurate word count maintenance during category removal
- Reduce tested Ruby versions to 2.7 and head
@cardmagic cardmagic self-assigned this Jul 31, 2024
- Update classifier gem from version 1.4.1 to 1.4.2 in Gemfile.lock
- Remove test for nonexistent category removal
- Rename and update test for category removal
- Add mutex_m requirement in test helper
- Add mutex_m gem to Gemfile and gemspec
- Update fast-stemmer dependency version in gemspec
- Remove explicit require of mutex_m in test_helper.rb
- Loosen fast-stemmer version constraint to ~> 1.0
- Add mutex_m dependency with version ~> 0.2
@cardmagic cardmagic merged commit d8c758c into master Jul 31, 2024
1 of 2 checks passed
@cardmagic cardmagic deleted the fix-race-condition-bug-deleting-categories branch July 31, 2024 14:59
cardmagic referenced this pull request Jul 31, 2024
Add remove_category functionality to Bayes classifier
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