original_docstring: 
          Counts the number of engaged users having a minimum number of conversation steps.
  
          :param collection: collection to connect to
          :param month: default is current month and max is last 6 months
          :param conversation_limit: conversation step number to determine engaged users
          :return: number of engaged users
          
docstring: Counts the number of engaged users having a minimum number of conversation steps.
docstring_tokens: Counts the number of engaged users having a minimum number of conversation steps .
code: def engaged_users(collection: Text, month: int = 1, conversation_limit: int = 10):
  
          """
          Counts the number of engaged users having a minimum number of conversation steps.
  
          :param collection: collection to connect to
          :param month: default is current month and max is last 6 months
          :param conversation_limit: conversation step number to determine engaged users
          :return: number of engaged users
          """
  
          client, message = HistoryProcessor.get_mongo_connection()
          message = ' '.join([message, f', collection: {collection}'])
          with client as client:
              db = client.get_database()
              conversations = db.get_collection(collection)
              values = []
              try:
                  values = list(
                       conversations.aggregate([{"$unwind": {"path": "$events", "includeArrayIndex": "arrayIndex"}},
                                                {"$match": {"events.event": {"$in": ["user", "bot"]},
                                                            "events.timestamp": {
                                                                "$gte": Utility.get_timestamp_previous_month(month)}}
                                                 },
                                                {"$group": {"_id": "$sender_id", "events": {"$push": "$events"},
                                                 "allevents": {"$push": "$events"}}},
                                                {"$unwind": "$events"},
                                                {"$project": {
                                                 "_id": 1,
                                                 "events": 1,
                                                 "following_events": {
                                                   "$arrayElemAt": [
                                                       "$allevents",
                                                       {"$add": [{"$indexOfArray": ["$allevents", "$events"]}, 1]}
                                                   ]
                                                 }
                                                 }},
                                                {"$project": {
                                                 "user_event": "$events.event",
                                                 "bot_event": "$following_events.event",
                                                 }},
                                               {"$match": {"user_event": "user", "bot_event": "bot"}},
                                               {"$group": {"_id": "$_id", "event": {"$sum": 1}}},
                                               {"$match": {"event": {"$gte": conversation_limit}}},
                                               {"$group": {"_id": None, "event": {"$sum": 1}}},
                                               {"$project": {
                                                "_id": 0,
                                                "event": 1,
                                                }}
                                                ], allowDiskUse=True)
                                             )
              except Exception as e:
                  logger.error(e)
                  message = '\n'.join([message, str(e)])
              if not values:
                  event = 0
              else:
                  event = values[0]['event'] if values[0]['event'] else 0
              return (
                  {"engaged_users": event},
                  message
              )
code_tokens: def engaged_users ( collection : Text , month : int = 1 , conversation_limit : int = 10 ) : client , message = HistoryProcessor . get_mongo_connection ( ) message = ' ' . join ( [ message , f', collection: {collection}' ] ) with client as client : db = client . get_database ( ) conversations = db . get_collection ( collection ) values = [ ] try : values = list ( conversations . aggregate ( [ { "$unwind" : { "path" : "$events" , "includeArrayIndex" : "arrayIndex" } } , { "$match" : { "events.event" : { "$in" : [ "user" , "bot" ] } , "events.timestamp" : { "$gte" : Utility . get_timestamp_previous_month ( month ) } } } , { "$group" : { "_id" : "$sender_id" , "events" : { "$push" : "$events" } , "allevents" : { "$push" : "$events" } } } , { "$unwind" : "$events" } , { "$project" : { "_id" : 1 , "events" : 1 , "following_events" : { "$arrayElemAt" : [ "$allevents" , { "$add" : [ { "$indexOfArray" : [ "$allevents" , "$events" ] } , 1 ] } ] } } } , { "$project" : { "user_event" : "$events.event" , "bot_event" : "$following_events.event" , } } , { "$match" : { "user_event" : "user" , "bot_event" : "bot" } } , { "$group" : { "_id" : "$_id" , "event" : { "$sum" : 1 } } } , { "$match" : { "event" : { "$gte" : conversation_limit } } } , { "$group" : { "_id" : None , "event" : { "$sum" : 1 } } } , { "$project" : { "_id" : 0 , "event" : 1 , } } ] , allowDiskUse = True ) ) except Exception as e : logger . error ( e ) message = '\n' . join ( [ message , str ( e ) ] ) if not values : event = 0 else : event = values [ 0 ] [ 'event' ] if values [ 0 ] [ 'event' ] else 0 return ( { "engaged_users" : event } , message )
short_docstring: Counts the number of engaged users having a minimum number of conversation steps.
short_docstring_tokens: Counts the number of engaged users having a minimum number of conversation steps .
comment: """
          Counts the number of engaged users having a minimum number of conversation steps.
  
          :param collection: collection to connect to
          :param month: default is current month and max is last 6 months
          :param conversation_limit: conversation step number to determine engaged users
          :return: number of engaged users
          """