original_docstring: 
          Total conversation time for bot.
  
          Calculates the duration of 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 users duration
          
docstring: Total conversation time for bot.
  Calculates the duration of between agent and users.
docstring_tokens: Total conversation time for bot . Calculates the duration of between agent and users .
code: def conversation_time(collection: Text, month: int = 1):
  
          """
          Total conversation time for bot.
  
          Calculates the duration of 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 users duration
          """
          client, message = HistoryProcessor.get_mongo_connection()
          message = ' '.join([message, f', collection: {collection}'])
          db = client.get_database()
          conversations = db.get_collection(collection)
          values = []
          try:
              values = list(conversations.aggregate([{"$unwind": "$events"},
                               {"$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",
                                   "time_diff": {
                                       "$subtract": ["$following_events.timestamp", "$events.timestamp"]
                                   }
                               }},
                               {"$match": {"user_event": "user", "bot_event": "bot"}},
                               {"$group": {"_id": "$_id", "time": {"$sum": "$time_diff"}}},
                               {"$project": {
                                   "sender_id": "$_id",
                                   "_id": 0,
                                   "time": 1,
                               }}
                               ], allowDiskUse=True)
                   )
          except Exception as e:
              logger.error(e)
              message = '\n'.join([message, str(e)])
          return values, message
code_tokens: def conversation_time ( collection : Text , month : int = 1 ) : client , message = HistoryProcessor . get_mongo_connection ( ) message = ' ' . join ( [ message , f', collection: {collection}' ] ) db = client . get_database ( ) conversations = db . get_collection ( collection ) values = [ ] try : values = list ( conversations . aggregate ( [ { "$unwind" : "$events" } , { "$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" , "time_diff" : { "$subtract" : [ "$following_events.timestamp" , "$events.timestamp" ] } } } , { "$match" : { "user_event" : "user" , "bot_event" : "bot" } } , { "$group" : { "_id" : "$_id" , "time" : { "$sum" : "$time_diff" } } } , { "$project" : { "sender_id" : "$_id" , "_id" : 0 , "time" : 1 , } } ] , allowDiskUse = True ) ) except Exception as e : logger . error ( e ) message = '\n' . join ( [ message , str ( e ) ] ) return values , message
short_docstring: Total conversation time for bot.
short_docstring_tokens: Total conversation time for bot .
comment: """
          Total conversation time for bot.
  
          Calculates the duration of 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 users duration
          """