{"id":19206785,"url":"https://github.com/hausgold/alarmable","last_synced_at":"2025-05-12T17:27:44.934Z","repository":{"id":28043459,"uuid":"110098841","full_name":"hausgold/alarmable","owner":"hausgold","description":"A reusable alarm extension to Active Record models","archived":false,"fork":false,"pushed_at":"2024-08-19T08:56:13.000Z","size":92,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-09-22T21:23:57.789Z","etag":null,"topics":["activejob","activerecord","activerecord-callbacks","alarms","concern","gem","notifications","oss","rails","ruby","ruby-gem"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/alarmable","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/hausgold.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2017-11-09T10:07:28.000Z","updated_at":"2024-08-19T08:56:16.000Z","dependencies_parsed_at":"2024-06-19T18:29:13.339Z","dependency_job_id":"868e83e5-3bcc-43b8-8509-a210f894eec6","html_url":"https://github.com/hausgold/alarmable","commit_stats":{"total_commits":38,"total_committers":3,"mean_commits":"12.666666666666666","dds":0.07894736842105265,"last_synced_commit":"075254ccc716e3762ad1862a14946f99f5c56986"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hausgold%2Falarmable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hausgold%2Falarmable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hausgold%2Falarmable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hausgold%2Falarmable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hausgold","download_url":"https://codeload.github.com/hausgold/alarmable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223829224,"owners_count":17210020,"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","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":["activejob","activerecord","activerecord-callbacks","alarms","concern","gem","notifications","oss","rails","ruby","ruby-gem"],"created_at":"2024-11-09T13:17:00.139Z","updated_at":"2024-11-09T13:17:00.264Z","avatar_url":"https://github.com/hausgold.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Alarmable](doc/assets/project.svg)\n\n[![Continuous Integration](https://github.com/hausgold/alarmable/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/hausgold/alarmable/actions/workflows/test.yml)\n[![Gem Version](https://badge.fury.io/rb/alarmable.svg)](https://badge.fury.io/rb/alarmable)\n[![Test Coverage](https://automate-api.hausgold.de/v1/coverage_reports/alarmable/coverage.svg)](https://knowledge.hausgold.de/coverage)\n[![Test Ratio](https://automate-api.hausgold.de/v1/coverage_reports/alarmable/ratio.svg)](https://knowledge.hausgold.de/coverage)\n[![API docs](https://automate-api.hausgold.de/v1/coverage_reports/alarmable/documentation.svg)](https://www.rubydoc.info/gems/alarmable)\n\nThis is a reusable alarm concern for Active Record models. It adds support for\nthe automatic maintenance of Active Job's which are scheduled for the given\nalarms. On alarm updates the jobs will be canceled and rescheduled. This is\nsupported only for Sidekiq, Delayed Job, resque and the Active Job TestAdapter.\n(See [ActiveJob::Cancel](https://github.com/y-yagi/activejob-cancel) for the\nlist of supported adapters)\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Database migration](#database-migration)\n  - [Active Record Model](#active-record-model)\n  - [Active Job](#active-job)\n- [Development](#development)\n- [Code of Conduct](#code-of-conduct)\n- [Contributing](#contributing)\n- [Releasing](#releasing)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'alarmable'\n```\n\nAnd then execute:\n\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install alarmable\n```\n\n## Usage\n\n### Database migration\n\nThis concern requires the persistence (and availability) of two properties.\n\n* The first is the JSONB array which holds the alarms. (`alarms`)\n* The seconds is the JSONB array which holds the ids of the\n  scheduled alarm jobs. (`alarm_jobs`)\n\n```bash\n$ rails generate migration AddAlarmsAndAlarmJobsToEntity \\\n  alarms:jsonb alarm_jobs:jsonb\n```\n\n### Active Record Model\n\nFurthermore a Active Record model which uses this concern must define the\nActive Job class which will be scheduled. (`alarm_job`) The user must also\ndefine the base date property of the owning side.\n(`alarm_base_date_property`) This base date is mandatory to calculate the\ncorrect alarm date/time. When the base date is not set (`nil`) no new\nnotification job will be enqueued. When the base date is unset on an update,\nthe previously enqueued job will be canceled.\n\n```ruby\n# Your Active Record Model\nclass Entity \u003c ApplicationRecord\n  include Alarmable\n  self.alarm_job = NotificationJob\n  self.alarm_base_date_property = :start_at\nend\n```\n\nThe alarms hash needs to be an array in the following format:\n\n```ruby\n[\n  {\n    \"channel\": \"email\",   # email, push, web_notification, etc..\n    \"before_minutes\": 15  # start_at - before_minutes, \u003e= 1\n\n    # [..] you can add custom properties if you like\n  }\n]\n```\n\n### Active Job\n\nThe given alarm job class will be scheduled with the following two arguments.\n\n* id - The class/instance id of the record which owns the alarm\n* alarm - The alarm hash itself (see the format above)\n\nA suitable alarm job perform method should look like this:\n\n```ruby\n# Your notification job\nclass NotificationJob \u003c ApplicationJob\n  # @param id [String] The entity id\n  # @param alarm [Hash] The alarm object\n  def perform(id, alarm)\n    # Do something special for `alarm.channel` ..\n  end\nend\n```\n\n## Development\n\nAfter checking out the repo, run `make install` to install dependencies. Then,\nrun `make test` to run the tests. You can also run `make shell-irb` for an\ninteractive prompt that will allow you to experiment.\n\n## Code of Conduct\n\nEveryone interacting in the project codebase, issue tracker, chat\nrooms and mailing lists is expected to follow the [code of\nconduct](./CODE_OF_CONDUCT.md).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/hausgold/alarmable. Make sure that every pull request adds\na bullet point to the [changelog](./CHANGELOG.md) file with a reference to the\nactual pull request.\n\n## Releasing\n\nThe release process of this Gem is fully automated. You just need to open the\nGithub Actions [Release\nWorkflow](https://github.com/hausgold/alarmable/actions/workflows/release.yml)\nand trigger a new run via the **Run workflow** button. Insert the new version\nnumber (check the [changelog](./CHANGELOG.md) first for the latest release) and\nyou're done.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhausgold%2Falarmable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhausgold%2Falarmable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhausgold%2Falarmable/lists"}