{"id":19339389,"url":"https://github.com/appfolio/ae_active_job_state","last_synced_at":"2025-10-07T17:09:23.872Z","repository":{"id":43687613,"uuid":"320702771","full_name":"appfolio/ae_active_job_state","owner":"appfolio","description":"Store ActiveJob status in ActiveRecord","archived":false,"fork":false,"pushed_at":"2025-04-17T18:17:07.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":57,"default_branch":"master","last_synced_at":"2025-08-18T05:53:47.919Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appfolio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-11T23:00:44.000Z","updated_at":"2025-04-17T18:17:11.000Z","dependencies_parsed_at":"2022-09-10T01:23:40.953Z","dependency_job_id":"079ea5db-acf1-4606-93da-0f8fed3e4bb9","html_url":"https://github.com/appfolio/ae_active_job_state","commit_stats":{"total_commits":26,"total_committers":3,"mean_commits":8.666666666666666,"dds":0.2692307692307693,"last_synced_commit":"b37e159f8e8c7d9dfa3b92040993a3782eb1db38"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/appfolio/ae_active_job_state","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfolio%2Fae_active_job_state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfolio%2Fae_active_job_state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfolio%2Fae_active_job_state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfolio%2Fae_active_job_state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appfolio","download_url":"https://codeload.github.com/appfolio/ae_active_job_state/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfolio%2Fae_active_job_state/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278811851,"owners_count":26050183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T03:21:53.094Z","updated_at":"2025-10-07T17:09:23.825Z","avatar_url":"https://github.com/appfolio.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AeActiveJobState\n\nThis gem use callbacks from ActiveJob to set job status and save them in ActiveRecord. It supports different states of job including pending, running, finished and failed. It also allows setting job progress and job result.\n\nThe table name is `ae_active_job_state_job_states`. It uses native JSON data type in SQL so make sure your SQL database supports that. For MySQL that means version 5.7 and later.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'ae_active_job_state'\n```\n\nAnd then execute:\n\n```bash\n$ bundle install\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install ae_active_job_state\n```\n\nThen you need to copy the migration over\n\n```bash\n$ rails generate ae_active_job_state\n```\n\n## Upgrading\n\nOccasionally, additional migrations may be required when updating this gem. The migration generator takes a\n`since_version` flag that will take the version you are upgrading from and add any required migrations since that\nversion.\n\n```bash\n$ rails generate ae_active_job_state --since_version 0.1.0\n```\n\n## Usage\n\n### Include this module in your job class\n\n```ruby\nclass AlwaysPassJob \u003c ActiveJob::Base\n  include AeActiveJobState::HasJobState\n  def perform(_params)\n    1\n  end\nend\n```\n\nIf you want to apply this on all job classes, you can even include it in ApplicationJob\n\n```ruby\nclass ApplicationJob \u003c ActiveJob::Base\n  include AeActiveJobState::HasJobState\nend\n\nclass AlwaysPassJob \u003c ApplicationJob\n  def perform(_params)\n    1\n  end\nend\n```\n\n### Get job state ID after enqueueing\n\n```ruby\njob = AlwaysPassJob.perform_later(1)\njob.job_state.id\n```\n\n### Set job progress\n\n```ruby\nclass HasProgressJob \u003c ApplicationJob\n  def perform(_params)\n    set_job_progress!('percent' =\u003e 20)\n  end\nend\n\njob = HasProgressJob.perform_later(1)\n# wait for job to execute\njob.job_state.progress == { 'percent' =\u003e 20 }\n```\n\n### Set job result\n\n```ruby\nclass HasResultJob \u003c ApplicationJob\n  def perform(_params)\n    set_job_result!('value' =\u003e 20)\n  end\nend\n\njob = HasResultJob.perform_later(1)\n# wait for job to finish\njob.job_state.result == { 'value' =\u003e 20 }\n```\n\n## Running test\n\nThis gem assumes MySQL running at port 3307 on IP address 127.0.0.1. The quickest way to set this up is to use docker:\n\n`docker run -d -v /tmp/mysql_data:/var/lib/mysql --name mysql5.7 -e MYSQL_ALLOW_EMPTY_PASSWORD=true -p 3307:3306 mysql:5.7`\n\nThen you can run rpsec `bundle exec rspec`\n\n## Running rubocop\n\n`bundle exec rubocop`\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfolio%2Fae_active_job_state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappfolio%2Fae_active_job_state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfolio%2Fae_active_job_state/lists"}