Graph Publication Workflow In V8 Deletes Spatial Views

by ADMIN 55 views

Introduction

The graph publication workflow in v8 has been implemented to allow for graph versioning by enabling draft (aka "editable future") graphs. This feature allows users to create and edit graphs in a draft state, and then publish or revert to a previous version. However, this workflow has been found to have a critical issue where spatial views get wiped on any graph publish/revert operation. In this article, we will explore the root cause of this issue and propose potential solutions to resolve it.

Understanding the Issue

The graph publication workflow in v8 involves deleting the draft graph and associated entities (nodes/nodegroups/cards/widgets etc) and recreating the target version graph from the serialized representation in the database. Spatial view model instances cascade delete if their geometry nodes are deleted, resulting in the loss of spatial views during the publish/revert operation.

Reproduction Steps

To reproduce the issue, follow these steps:

dev/8.0.x

  1. Create a Model with a String Node and a GeoJSON Node: Create a model with a string node and a geojson node. Save the edits to create a draft graph.
  2. Publish the Graph: Publish the graph to create a new version.
  3. Show IDs and Keep the Tab Open: Click show ids and keep this tab open to be able to copy the IDs easily.
  4. Add a Spatial View: In a new tab, navigate to Django admin > Spatial views > Add.
  5. Create a Spatial View: In the form, add a slug, pick the geojson node from the geometry node dropdown, pick a language, and add the following JSON array to attributenodes: [{"nodeid": <string node pk>; "description": "string"}]. Save the spatial view.
  6. Add a Description to the Graph: In the graph editor tab, add a description "added spatial view".
  7. Save Edits: Save the edits to update the graph.
  8. Create a New Publication: Create a new publication.
  9. Refresh Admin: Refresh the admin page.

Result

After following the reproduction steps, you will find that no spatial views exist.

Proposed Solutions

To resolve the issue of spatial views getting wiped on graph publish/revert, we propose the following solutions:

1. Change SpatialView.geometrynode to on_delete=models.SET_NULL

One possible solution is to change the SpatialView.geometrynode field to use on_delete=models.SET_NULL. This will prevent the spatial view from being deleted when its geometry node is deleted.

2. Store a Reference to the Target Geometry Node

Another solution is to store a reference to the target geometry node before deleting it. This can be done by creating a temporary reference to the geometry node before deleting it, and then re-establishing the link after the publishing operation is done.

3. Re-establish the Link After Publishing Operation

After the publishing operation is done, we can re-establish the link between the spatial view and the geometry node. This can be done by updating the SpatialView.geometrynode field to point to the newly created geometry node.

Conclusion

The graph publication workflow in v8 has been found to have a critical issue where spatial views get wiped on any graph publish/revert operation. We have proposed three potential solutions to resolve this issue, including changing the SpatialView.geometrynode field to use on_delete=models.SET_NULL, storing a reference to the target geometry node, and re-establishing the link after the publishing operation is done. By implementing one or more of these solutions, we can ensure that spatial views are preserved during the graph publication workflow.

Future Work

To further improve the graph publication workflow, we can consider the following future work:

  • Implementing a more robust spatial view management system that can handle changes to the geometry node without deleting the spatial view.
  • Adding additional logging and debugging mechanisms to help identify and resolve issues with the graph publication workflow.
  • Exploring alternative solutions, such as using a separate database table to store spatial view metadata, to improve the performance and scalability of the graph publication workflow.

Introduction

In our previous article, we explored the issue of spatial views getting wiped on graph publish/revert in the graph publication workflow in v8. We proposed three potential solutions to resolve this issue, including changing the SpatialView.geometrynode field to use on_delete=models.SET_NULL, storing a reference to the target geometry node, and re-establishing the link after the publishing operation is done. In this article, we will answer some frequently asked questions (FAQs) related to this issue and provide additional insights and guidance.

Q: What is the root cause of the issue?

A: The root cause of the issue is that spatial view model instances cascade delete if their geometry nodes are deleted, resulting in the loss of spatial views during the publish/revert operation.

Q: Why is this issue only happening in v8?

A: This issue is only happening in v8 because of the changes made to the graph publication workflow, which involves deleting the draft graph and associated entities (nodes/nodegroups/cards/widgets etc) and recreating the target version graph from the serialized representation in the database.

Q: How can I reproduce the issue?

A: To reproduce the issue, follow the steps outlined in our previous article, including creating a model with a string node and a geojson node, publishing the graph, adding a spatial view, and refreshing the admin page.

Q: What are the potential solutions to resolve this issue?

A: We proposed three potential solutions to resolve this issue:

  1. Change SpatialView.geometrynode to on_delete=models.SET_NULL: This will prevent the spatial view from being deleted when its geometry node is deleted.
  2. Store a Reference to the Target Geometry Node: This involves creating a temporary reference to the geometry node before deleting it, and then re-establishing the link after the publishing operation is done.
  3. Re-establish the Link After Publishing Operation: This involves updating the SpatialView.geometrynode field to point to the newly created geometry node after the publishing operation is done.

Q: Which solution is the most effective?

A: The most effective solution will depend on the specific requirements and constraints of your project. However, changing the SpatialView.geometrynode field to use on_delete=models.SET_NULL is a simple and effective solution that can resolve the issue.

Q: How can I implement the proposed solutions?

A: To implement the proposed solutions, you will need to modify the code that handles the graph publication workflow. This may involve updating the models, views, and templates to reflect the changes.

Q: What are the benefits of resolving this issue?

A: Resolving this issue will improve the overall user experience and reliability of the graph publication workflow in v8. It will also prevent the loss of spatial views during the publish/revert operation, which can be critical for certain applications.

Q: What are the next steps?

A: The next steps will depend on the specific requirements and constraints of your project. However, we recommend implementing one or more of the proposed solutions to resolve the issue and improve the graph publication workflow in v8.

Conclusion

In this article, we answered some frequently asked questions related to the issue of spatial views getting wiped on graph publish/revert in the graph publication workflow in v8. We also provided additional insights and guidance on implementing the proposed solutions to resolve this issue. By resolving this issue, you can improve the overall user experience and reliability of the graph publication workflow in v8.