# Path: virtool/db/utils.py
# async def get_one_field(collection, field: str, query: Union[str, Dict]) -> Any:
#     """
#     Get the value for a single `field` from a single document matching the `query`.
# 
#     :param collection: the database collection to search
#     :param field: the field to return
#     :param query: the document matching query
#     :return: the field
# 
#     """
#     projected = await collection.find_one(query, [field])
# 
#     if projected is None:
#         return None
# 
#     return projected.get(field)
# 
# Path: virtool/users/utils.py
# def limit_permissions(permissions: dict, limit_filter: dict) -> dict:
#     """
#     Make sure permission values in `permissions` do not exceed those in `limit_filter`. Returns a
#     filtered set of permissions.
# 
#     :param limit_filter: the limiting permissions that cannot be exceeded
#     :param permissions: a permissions to filter
#     :return: filtered permissions
# 
#     """
#     return {p: (permissions.get(p, False) and limit_filter[p]) for p in permissions}


import virtool.account.db
import virtool.http.auth
import virtool.http.routes
import virtool.validators
from aiohttp.web import HTTPNoContent, Request, Response
from aiohttp.web_exceptions import HTTPBadRequest
from virtool.analyses.utils import WORKFLOW_NAMES
from virtool.api.response import NotFound, json_response
from virtool.db.utils import get_one_field
from virtool.http.schema import schema
from virtool.http.utils import set_session_id_cookie, set_session_token_cookie
from virtool.users.checks import check_password_length
from virtool.users.db import validate_credentials
from virtool.users.sessions import create_reset_code, replace_session
from virtool.users.utils import limit_permissions
from virtool.utils import base_processor
    """
    account_settings = await get_one_field(
        req.app["db"].users, "settings", req["client"].user_id
    )

    return json_response(account_settings)


@routes.patch("/account/settings")
@schema(
    {
        "show_ids": {"type": "boolean", "required": False},
        "skip_quick_analyze_dialog": {"type": "boolean", "required": False},
        "quick_analyze_workflow": {
            "type": "string",
            "allowed": WORKFLOW_NAMES,
            "required": False,
        },
    }
)
async def update_settings(req: Request) -> Response:
    """
    Update account settings.

    """
    db = req.app["db"]
    data = req["data"]

    user_id = req["client"].user_id


# Path: virtool/db/utils.py
# async def get_one_field(collection, field: str, query: Union[str, Dict]) -> Any:
#     """
#     Get the value for a single `field` from a single document matching the `query`.
# 
#     :param collection: the database collection to search
#     :param field: the field to return
#     :param query: the document matching query
#     :return: the field
# 
#     """
#     projected = await collection.find_one(query, [field])
# 
#     if projected is None:
#         return None
# 
#     return projected.get(field)
# 
# Path: virtool/users/utils.py
# def limit_permissions(permissions: dict, limit_filter: dict) -> dict:
#     """
#     Make sure permission values in `permissions` do not exceed those in `limit_filter`. Returns a
#     filtered set of permissions.
# 
#     :param limit_filter: the limiting permissions that cannot be exceeded
#     :param permissions: a permissions to filter
#     :return: filtered permissions
# 
#     """
#     return {p: (permissions.get(p, False) and limit_filter[p]) for p in permissions}


# Path: virtool/account/api.py
import virtool.account.db
import virtool.http.auth
import virtool.http.routes
import virtool.validators
from aiohttp.web import HTTPNoContent, Request, Response
from aiohttp.web_exceptions import HTTPBadRequest
from virtool.analyses.utils import WORKFLOW_NAMES
from virtool.api.response import NotFound, json_response
from virtool.db.utils import get_one_field
from virtool.http.schema import schema
from virtool.http.utils import set_session_id_cookie, set_session_token_cookie
from virtool.users.checks import check_password_length
from virtool.users.db import validate_credentials
from virtool.users.sessions import create_reset_code, replace_session
from virtool.users.utils import limit_permissions
from virtool.utils import base_processor

    """
    account_settings = await get_one_field(
        req.app["db"].users, "settings", req["client"].user_id
    )

    return json_response(account_settings)


@routes.patch("/account/settings")
@schema(
    {
        "show_ids": {"type": "boolean", "required": False},
        "skip_quick_analyze_dialog": {"type": "boolean", "required": False},
        "quick_analyze_workflow": {
            "type": "string",
            "allowed": WORKFLOW_NAMES,
            "required": False,
        },
    }
)
async def update_settings(req: Request) -> Response:
    """
    Update account settings.

    """
    db = req.app["db"]
    data = req["data"]

    user_id = req["client"].user_id


    settings_from_db = await get_one_field(db.users, "settings", user_id)