original_docstring: 
          Archives conversations based on month to conversations_archive DB
  
          :param collection: collection to connect to
          :param sender_id: user id
          :param timestamp_req: the timestamp based on month up to which chat to be archived
          :return: none
          
docstring: Archives conversations based on month to conversations_archive DB
docstring_tokens: Archives conversations based on month to conversations_archive DB
code: def archive_user_history(collection: Text, sender_id: Text, timestamp_req: float):
  
          """
          Archives conversations based on month to conversations_archive DB
  
          :param collection: collection to connect to
          :param sender_id: user id
          :param timestamp_req: the timestamp based on month up to which chat to be archived
          :return: none
          """
          archive_db = Utility.environment['history_server']['deletion']['archive_db']
          client, _ = HistoryProcessor.get_mongo_connection()
          archive_collection = f"{collection}.{sender_id}"
  
          with client as client:
              try:
                  db = client.get_database()
                  conversations = db.get_collection(collection)
                  conversations.aggregate([{"$match": {"sender_id": sender_id}},
                                           {"$unwind": {"path": "$events"}},
                                           {"$match": {"events.timestamp": {
                                               "$lt": timestamp_req}}},
                                           {"$unset": "_id"},
                                           {"$merge": {"into": {"db": archive_db, "coll": archive_collection},
                                                       "on": "_id",
                                                       "whenMatched": "keepExisting",
                                                       "whenNotMatched": "insert"}}
                                           ])
              except Exception as e:
                  logger.error(e)
                  raise AppException(e)
code_tokens: def archive_user_history ( collection : Text , sender_id : Text , timestamp_req : float ) : archive_db = Utility . environment [ 'history_server' ] [ 'deletion' ] [ 'archive_db' ] client , _ = HistoryProcessor . get_mongo_connection ( ) archive_collection = f"{collection}.{sender_id}" with client as client : try : db = client . get_database ( ) conversations = db . get_collection ( collection ) conversations . aggregate ( [ { "$match" : { "sender_id" : sender_id } } , { "$unwind" : { "path" : "$events" } } , { "$match" : { "events.timestamp" : { "$lt" : timestamp_req } } } , { "$unset" : "_id" } , { "$merge" : { "into" : { "db" : archive_db , "coll" : archive_collection } , "on" : "_id" , "whenMatched" : "keepExisting" , "whenNotMatched" : "insert" } } ] ) except Exception as e : logger . error ( e ) raise AppException ( e )
short_docstring: Archives conversations based on month to conversations_archive DB
short_docstring_tokens: Archives conversations based on month to conversations_archive DB
comment: """
          Archives conversations based on month to conversations_archive DB
  
          :param collection: collection to connect to
          :param sender_id: user id
          :param timestamp_req: the timestamp based on month up to which chat to be archived
          :return: none
          """