Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • C chouette-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 36
    • Merge requests 36
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Administrator
  • chouette-core
  • Merge requests
  • !459

Merged
Created Apr 06, 2018 by Administrator@rootMaintainer

6407: Route: Change `#calculate_costs!` to `after_commit` callback

  • Overview 0
  • Commits 2
  • Changes 3

Created by: teddywing

Use an after_commit instead of an after_save. The after_save could cause intermittent problems due to Sidekiq starting before the record/transaction actually gets committed to the database. In those cases, the record wouldn't be found and cause an error.

With an after_commit callback, the record is sure to be committed before Sidekiq takes over.

Additionally, limit the callback to :create and :update because otherwise it will be active on :destroy by default also. This work isn't relevant on destroy, so don't do it then.

Update the tests:

  • Update labels
  • Use build instead of create because we're saving the record at the end anyway so we don't need an object that starts out persisted
  • Use truncation: true for these tests because otherwise the commit callback doesn't get called due to transactional teardown

Refs #6407

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: 6407-route--calculate-way-costs-on-after_commit-instead-of-a