<commit_before>_ = 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) -> (opts) ->
  { topic, subscription } = opts
  new Type _(opts).omit([ "topic", "subscription" ]).defaults(path: "#{topic}/#{subscription}").value()


module.exports =
  newNotification: ({ message }) ->
    message: _.omit message, "Sent"
    meta:
      insertionTime: message.Sent
      dequeueCount: 0
    type: "sb"

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

  delayObserver: create DelayObserver

  deadLetterSucceeded: create DeadLetterSucceeded

  didLastRetry: create DidLastRetry
<commit_msg>Adding enqueuedTime and deliveryCount of ServiceBus message<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) -> (opts) ->
  { topic, subscription } = opts
  new Type _(opts).omit([ "topic", "subscription" ]).defaults(path: "#{topic}/#{subscription}").value()


module.exports =
  newNotification: ({ context: { bindingData : { enqueuedTimeUtc, deliveryCount } }, message }) ->
    message: _.omit message, "Sent"
    meta:
      insertionTime: enqueuedTimeUtc
      dequeueCount: deliveryCount
    type: "sb"

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

  delayObserver: create DelayObserver

  deadLetterSucceeded: create DeadLetterSucceeded

  didLastRetry: create DidLastRetry

{'fraction_non_alphanumeric': 0.11944677284157586, 'fraction_numerical': 0.00041911148365465214, 'mean_word_length': 5.61218836565097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '656127', 'n_tokens_mistral': 718, 'n_tokens_neox': 701, 'n_words': 136}