def to_archive(httpreq: Request, request: DFIQSearchRequest) -> FileResponse:
    """Compresses DFIQ objects into a ZIP archive.

    The structure of the archive is as follows:
    - {public, internal}/
      - type/
        - dfiq_id.yaml
    """
    dfiq_objects, _ = dfiq.DFIQBase.filter(
        query_args=request.query,
        offset=request.page * request.count,
        count=request.count,
        sorting=request.sorting,
        aliases=request.filter_aliases,
        user=httpreq.state.user,
    )

    _TYPE_TO_DUMP_DIR = {
        dfiq.DFIQType.scenario: "scenarios",
        dfiq.DFIQType.facet: "facets",
        dfiq.DFIQType.question: "questions",
    }

    with tempfile.TemporaryDirectory() as tempdir:
        public_objs = []
        internal_objs = []
        for obj in dfiq_objects:
            if obj.dfiq_tags and "internal" in obj.dfiq_tags:
                internal_objs.append(obj)
            else:
                if obj.type == dfiq.DFIQType.question:
                    public_version = obj.model_copy()
                    internal_approaches = False
                    for approach in obj.approaches:
                        if "internal" in approach.tags:
                            internal_approaches = True
                            break
                    if internal_approaches:
                        public_version.approaches = [
                            a for a in obj.approaches if "internal" not in a.tags
                        ]
                        public_objs.append(public_version)
                        internal_objs.append(obj)
                    else:
                        public_objs.append(obj)
                else:
                    public_objs.append(obj)

        for dir_name in ["public", "internal"]:
            os.makedirs(f"{tempdir}/{dir_name}")

        for obj in public_objs:
            with open(f"{tempdir}/public/{obj.uuid}.yaml", "w") as f:
                f.write(obj.to_yaml())

        for obj in internal_objs:
            with open(f"{tempdir}/internal/{obj.uuid}.yaml", "w") as f:
                f.write(obj.to_yaml())

        with tempfile.NamedTemporaryFile(delete=False) as archive:
            with ZipFile(archive, "w") as zipf:
                for obj in public_objs:
                    zipf.write(
                        f"{tempdir}/public/{obj.uuid}.yaml",
                        f"public/{_TYPE_TO_DUMP_DIR[obj.type]}/{obj.uuid}.yaml",
                    )
                for obj in internal_objs:
                    zipf.write(
                        f"{tempdir}/internal/{obj.uuid}.yaml",
                        f"internal/{_TYPE_TO_DUMP_DIR[obj.type]}/{obj.uuid}.yaml",
                    )

    return FileResponse(archive.name, media_type="application/zip", filename="dfiq.zip")
Compresses DFIQ objects into a ZIP archive.

    The structure of the archive is as follows:
    - {public, internal}/
      - type/
        - dfiq_id.yaml
    
core/web/apiv2/dfiq.py