<commit_before># Slackiq

Slackiq integrates [Slack](https://slack.com/) and [Sidekiq](http://sidekiq.org) so that you can have vital information about your Sidekiq jobs sent directly to your team's Slack.

![demo](http://i.imgur.com/4NLq2rP.gif)

## Installation

Add this line to your Gemfile:

`gem 'slackiq'`

Then run:

`bundle install`

## Configuration

First, set up any number of Slack Incoming Webhooks [from your Slack](https://slack.com/services/new/incoming-webhook).

Then, you only need to call the `configure` method when your application launches to configure all of the webhooks to which you want to post. If you're using Rails, create an initializer at `config/initializers/slackiq.rb`. Here's an example:

```
Slackiq.configure( web_scrapes: 'https://hooks.slack.com/services/HA298HF2/ALSKF2451/lknsaHHA2323KKDKND', 
                   data_processing: 'https://hooks.slack.com/services/HA298HF2/ALSKF2451/H24dLKAHD22423')
```

`:web_scrapes` and `data_processing` are examples of keys. Use whatever keys you want.

## Usage

You can call `notify` to send a nicely-formatted notification to your Slack. You can call `notify`

* Inside the Sidekiq Pro `on_success` or `on_complete` callback (not available on regular Sidekiq--only Pro)
* From inside a Sidekiq worker while it's running, in which case you should pass in the `bid` to the `perform` method of the worker

The `notify` method has a single Hash parameter. Here are the keys and values in the Hash:
* `:webhook_name` The name of the webhook (Symbol) that you configured (eg. `:web_scrapes` or `:data_processing`)
* `:title` The title of the notification (String)
* `:status` An instance of `Sidekiq::Batch::Status`
* Any other keys and values (both Strings) can be added too, and they'll be added to the Slack notification!

If you haven't used batches with Sidekiq Pro before, [read this first](https://github.com/mperham/sidekiq/wiki/Batches).

Here's an example showing how you would use Slackiq to send a notification to your Slack when your Sidekiq batch completes:

```<commit_msg>added ruby syntax highlighting for readme<commit_after># Slackiq

Slackiq integrates [Slack](https://slack.com/) and [Sidekiq](http://sidekiq.org) so that you can have vital information about your Sidekiq jobs sent directly to your team's Slack.

![demo](http://i.imgur.com/4NLq2rP.gif)

## Installation

Add this line to your Gemfile:

`gem 'slackiq'`

Then run:

`bundle install`

## Configuration

First, set up any number of Slack Incoming Webhooks [from your Slack](https://slack.com/services/new/incoming-webhook).

Then, you only need to call the `configure` method when your application launches to configure all of the webhooks to which you want to post. If you're using Rails, create an initializer at `config/initializers/slackiq.rb`. Here's an example:

```
Slackiq.configure( web_scrapes: 'https://hooks.slack.com/services/HA298HF2/ALSKF2451/lknsaHHA2323KKDKND', 
                   data_processing: 'https://hooks.slack.com/services/HA298HF2/ALSKF2451/H24dLKAHD22423')
```

`:web_scrapes` and `data_processing` are examples of keys. Use whatever keys you want.

## Usage

You can call `notify` to send a nicely-formatted notification to your Slack. You can call `notify`

* Inside the Sidekiq Pro `on_success` or `on_complete` callback (not available on regular Sidekiq--only Pro)
* From inside a Sidekiq worker while it's running, in which case you should pass in the `bid` to the `perform` method of the worker

The `notify` method has a single Hash parameter. Here are the keys and values in the Hash:
* `:webhook_name` The name of the webhook (Symbol) that you configured (eg. `:web_scrapes` or `:data_processing`)
* `:title` The title of the notification (String)
* `:status` An instance of `Sidekiq::Batch::Status`
* Any other keys and values (both Strings) can be added too, and they'll be added to the Slack notification!

If you haven't used batches with Sidekiq Pro before, [read this first](https://github.com/mperham/sidekiq/wiki/Batches).

Here's an example showing how you would use Slackiq to send a notification to your Slack when your Sidekiq batch completes:

```ruby
{'fraction_non_alphanumeric': 0.09649543927028324, 'fraction_numerical': 0.013922227556409025, 'mean_word_length': 4.661684782608695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3031733', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1279, 'n_words': 516}