Get unbuilt changes 404
- building a new index results in `GET http://localhost:9950/api/indexes/unbuilt 404 (Not Found)`
(same for `/api/refs/:refId/indexes/unbuilt`)
diff --git a/virtool/api/references.py b/virtool/api/references.py
index 1d73b046c..1b1b3b743 100644
--- a/virtool/api/references.py
+++ b/virtool/api/references.py
@@ -95,6 +95,16 @@ async def find_history(req):
         "reference.id": ref_id
     }
 
+    unbuilt = req.query.get("unbuilt", None)
+
+    if unbuilt == "true":
+        base_query["index.id"] = "unbuilt"
+
+    elif unbuilt == "false":
+        base_query["index.id"] = {
+            "$ne": "unbuilt"
+        }
+
     data = await virtool.db.history.find(
         db,
         req.query,
@@ -196,6 +206,7 @@ async def create(req):
 
         document = await virtool.db.references.create_for_import(
             db,
+            settings,
             data["name"],
             data["description"],
             data["public"],
@@ -300,26 +311,6 @@ async def edit(req):
     return json_response(document)
 
 
-@routes.get("/api/refs/{ref_id}/unbuilt")
-async def get_unbuilt_changes(req):
-    """
-    Get a JSON document describing the unbuilt changes that could be used to create a new index.
-
-    """
-    db = req.app["db"]
-
-    ref_id = req.match_info["ref_id"]
-
-    history = await db.history.find({
-        "reference.id": ref_id,
-        "index.id": "unbuilt"
-    }, virtool.db.history.LIST_PROJECTION).to_list(None)
-
-    return json_response({
-        "history": [virtool.utils.base_processor(c) for c in history]
-    })
-
-
 @routes.delete("/api/refs/{ref_id}")
 async def remove(req):
     """
diff --git a/virtool/db/history.py b/virtool/db/history.py
index 1e2463b3f..a2da3c178 100644
--- a/virtool/db/history.py
+++ b/virtool/db/history.py
@@ -116,7 +116,7 @@ async def add(db, method_name, old, new, description, user_id):
     return document
 
 
-async def find(db, req_query, base_query=None):
+async def find(db, req_query, base_query=None, unbuilt=False):
     data = await paginate(
         db.history,
         {},
['virtool/api/references.py', 'virtool/db/history.py']