original_docstring: 
          Computes the trend for new user count
  
          :param collection: collection to connect to
          :param month: default is 6 months
          :return: dictionary of counts of new users for the previous months
          
docstring: Computes the trend for new user count
docstring_tokens: Computes the trend for new user count
code: def new_users_range(collection: Text, month: int = 6):
  
          """
          Computes the trend for new user count
  
          :param collection: collection to connect to
          :param month: default is 6 months
          :return: dictionary of counts of new users for the previous months
          """
  
          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.name": {"$regex": ".*session_start*.", "$options": "$i"}}},
                                            {"$group": {"_id": '$sender_id',
                                                        "latest_event_time": {"$first": "$events.timestamp"}}},
                                            {"$match": {"latest_event_time": {
                                                "$gte": Utility.get_timestamp_previous_month(month)}}},
                                            {"$addFields": {"month": {
                                                "$month": {"$toDate": {"$multiply": ["$latest_event_time", 1000]}}}}},
  
                                            {"$group": {"_id": "$month", "count": {"$sum": 1}}},
                                            {"$project": {"_id": 1, "count": 1}}
                                            ]))
              except Exception as e:
                  logger.error(e)
                  message = '\n'.join([message, str(e)])
              new_users = {d['_id']: d['count'] for d in values}
              return (
                  {"new_user_range": new_users},
                  message
              )
code_tokens: def new_users_range ( collection : Text , month : int = 6 ) : 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.name" : { "$regex" : ".*session_start*." , "$options" : "$i" } } } , { "$group" : { "_id" : '$sender_id' , "latest_event_time" : { "$first" : "$events.timestamp" } } } , { "$match" : { "latest_event_time" : { "$gte" : Utility . get_timestamp_previous_month ( month ) } } } , { "$addFields" : { "month" : { "$month" : { "$toDate" : { "$multiply" : [ "$latest_event_time" , 1000 ] } } } } } , { "$group" : { "_id" : "$month" , "count" : { "$sum" : 1 } } } , { "$project" : { "_id" : 1 , "count" : 1 } } ] ) ) except Exception as e : logger . error ( e ) message = '\n' . join ( [ message , str ( e ) ] ) new_users = { d [ '_id' ] : d [ 'count' ] for d in values } return ( { "new_user_range" : new_users } , message )
short_docstring: Computes the trend for new user count
short_docstring_tokens: Computes the trend for new user count
comment: """
          Computes the trend for new user count
  
          :param collection: collection to connect to
          :param month: default is 6 months
          :return: dictionary of counts of new users for the previous months
          """