Exemplo n.º 1
0
def public_trained_projects(organisation_name):
    """
    :param organisation_name:
    :return:
    """
    manager = ProjectManager()
    query = {
        "$and": [{
            "organisation_name": organisation_name
        }, {
            "visibility": "public"
        }, {
            "ner.status": "trained"
        }, {
            "ir.status": "trained"
        }, {
            "masterBot": False
        }]
    }
    # query = {"$and": [{"visibility": "public"}, {"ner.status": "trained"}, {"ir.status": "trained"},
    # {"masterBot": False}]}
    projection = {"name": 1, "serviceid": 1}
    data = manager.exists(query)
    if data:
        projects_to_import = manager.find(query, projection)
        logger.info("public trained projects found in PR DB")
        return projects_to_import
    else:
        return False
Exemplo n.º 2
0
def user_trained_projects(userid):
    """
    :param userid:
    :return:
    """
    manager = ProjectManager()
    query = {
        "$and": [{
            "createdBy": ObjectId(userid)
        }, {
            "ner.status": "trained"
        }, {
            "ir.status": "trained"
        }, {
            "visibility": "private"
        }, {
            "masterBot": False
        }]
    }
    # query = {"$and": [{"createdBy": ObjectId(userid)}, {"ner.status": "trained"}, {"ir.status": "trained"},
    #                   {"visibility": "private"}]}
    projection = {"name": 1, "serviceid": 1}
    data = manager.exists(query)
    if data:
        projects_to_import = manager.find(query, projection)
        logger.info("user trained projects found in PR DB.")
        return projects_to_import
    else:
        return False
def validate_project_organisation(project_id, organisation_name):
    manager = ProjectManager()
    query = {
        "$and": [{
            "_id": ObjectId(project_id)
        }, {
            "organisation_name": organisation_name
        }]
    }
    if manager.exists(query):
        return True
    else:
        return False
Exemplo n.º 4
0
def delete_project_if_exists(given_serviceid):
    '''
    delete_project_if_exists
    '''

    manager = ProjectManager()
    query = {"serviceid": given_serviceid}
    data = manager.exists(query)
    if data:
        manager.delete(query)
        logger.info("project deleted from PR DB.")
    ds_manager = DatasourceManager()
    data = ds_manager.exists(query)
    if data:
        ds_manager.delete(query)
        logger.info("project deleted from DS DB.")