original_docstring: 
          Total conversation steps for bot.
  
          calculates the number of conversation steps between agent and users
  
          :param collection: collection to connect to
          :param month: default is current month and max is last 6 months
          :return: list of conversation step count
          
docstring: Total conversation steps for bot.
  calculates the number of conversation steps between agent and users
docstring_tokens: Total conversation steps for bot . calculates the number of conversation steps between agent and users
code: def conversation_steps(collection: Text, month: int = 1):
  
          """
          Total conversation steps for bot.
  
          calculates the number of conversation steps between agent and users
  
          :param collection: collection to connect to
          :param month: default is current month and max is last 6 months
          :return: list of conversation step count
          """
          values = []
          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)
              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}}},
                                   {"$project": {
                                       "sender_id": "$_id",
                                       "_id": 0,
                                       "event": 1,
                                   }}
                                   ], allowDiskUse=True)
                          )
              except Exception as e:
                  logger.error(e)
                  message = '\n'.join([message, str(e)])
  
              return values, message
code_tokens: def conversation_steps ( collection : Text , month : int = 1 ) : values = [ ] 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 ) 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 } } } , { "$project" : { "sender_id" : "$_id" , "_id" : 0 , "event" : 1 , } } ] , allowDiskUse = True ) ) except Exception as e : logger . error ( e ) message = '\n' . join ( [ message , str ( e ) ] ) return values , message
short_docstring: Total conversation steps for bot.
short_docstring_tokens: Total conversation steps for bot .
comment: """
          Total conversation steps for bot.
  
          calculates the number of conversation steps between agent and users
  
          :param collection: collection to connect to
          :param month: default is current month and max is last 6 months
          :return: list of conversation step count
          """