<commit_before>_ = require "lodash"
DelayObserver = require "../observers/delay.observer"

MeliUsersThanNotBelongsToProducteca = process.env.MeliUsersThanNotBelongsToProducteca?.split(",") or []
MeliUsersThanCanNotRefreshAccessToken = process.env.MeliUsersThanCanNotRefreshAccessToken?.split(",") or []

IgnoredUsers = _.concat MeliUsersThanNotBelongsToProducteca, MeliUsersThanCanNotRefreshAccessToken

module.exports =
  newNotification: ({ context: { bindingData : { insertionTime, dequeueCount } }, message }) ->
    message: message
    meta: { insertionTime, dequeueCount }
    type: "as"

  shouldBeIgnored: ({ notification }) ->
    _.includes IgnoredUsers, notification?.message?.user_id?.toString()

  delayObserver: ({ redis, app, queue }) ->
    new DelayObserver { redis, app, path: queue }

  deadLetterSucceeded: -> throw new Error "not supported `deadLetterSucceeded`"
  didLastRetry: -> throw new Error "not supported `didLastRetry`"
<commit_msg>Support observer of queue source<commit_after>_ = require "lodash"
DelayObserver = require "../observers/delay.observer"
DeadLetterSucceeded = require "../observers/deadLetterSucceeded.observer"
DidLastRetry = require "../observers/didLastRetry.observer"

MeliUsersThanNotBelongsToProducteca = process.env.MeliUsersThanNotBelongsToProducteca?.split(",") or []
MeliUsersThanCanNotRefreshAccessToken = process.env.MeliUsersThanCanNotRefreshAccessToken?.split(",") or []

IgnoredUsers = _.concat MeliUsersThanNotBelongsToProducteca, MeliUsersThanCanNotRefreshAccessToken

create = (Type) -> ({ redis, app, queue }) ->
  new Type { redis, app, path: "#{queue}" }

module.exports =
  newNotification: ({ context: { bindingData : { insertionTime, dequeueCount } }, message }) ->
    message: message
    meta: { insertionTime, dequeueCount }
    type: "as"

  shouldBeIgnored: ({ notification }) ->
    _.includes IgnoredUsers, notification?.message?.user_id?.toString()

  delayObserver: create DelayObserver
  deadLetterSucceeded: create DeadLetterSucceeded
  didLastRetry: create DidLastRetry

{'fraction_non_alphanumeric': 0.11495372625426206, 'fraction_numerical': 0.0, 'mean_word_length': 5.712418300653595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, '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': '340630', 'n_tokens_mistral': 613, 'n_tokens_neox': 599, 'n_words': 124}