Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CiviLink model and Graph API #1510

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

reedjones
Copy link

start at closing #149

#1438 (comment)
added a basic graph template at threads/templates/graph.html
graph visual is still kinda wonky, need to fix it but the basic foundation is there

Description:

This PR introduces a graph-based API and utilities for the application, including:

Graph Data API:

Endpoints for analyzing relationships between entities using networkx.
Get the most caused problem (/api/graph/most-caused-problem).
Get the most effective solution (/api/graph/most-effective-solution).
Retrieve the shortest path between a problem and a solution (/api/graph/shortest-path/<problem_id>/<solution_id>).
Export graph data in a Cytoscape-compatible format (/api/graph/data).
Management Command for Dummy Data:

A new Django management command, load_graph_dummy_data, creates dummy Civi and CiviLink objects for testing graph functionalities.
Includes predefined dummy data with relationships like response, rebuttal, and support.
Graph Utilities:

Added graphs.py with utility functions to:
Load graph data from the database.
Analyze graph metrics like the most caused problems, most effective solutions, and shortest paths.
Model Enhancements:

Extended the Civi and CiviLink models to support graph-related functionality.
Civi model now includes methods for exporting graph-compatible data (node, weight, etc.).
CiviLink model supports edge representation in graphs with a relation_type field.
URL Configuration:

Updated URL patterns to include the new graph_api endpoints.
Highlights:

Added CiviLink model to represent directed relationships between Civi objects.
New API endpoints powered by networkx enable advanced graph-based analysis and insights.
Dummy data loader ensures quick setup for development and testing.

Introduces a CiviLink model to represent the graph's directed edges
 a
la
CiviWiki#1438 (comment)
added
a basic graph template at threads/templates/graph.html
added library
cytoscapejs for graph viz
added networkx library for graph
(python)
graph visual is still kinda wonky, need to fix it but the basic
gist of it is there kinda sorta

a start at closing
CiviWiki#149
feat(threads): threads.models, threads.graphs
@pep8speaks
Copy link

Hello @reedjones! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 31:121: E501 line too long (134 > 120 characters)
Line 40:121: E501 line too long (124 > 120 characters)

Line 54:60: E231 missing whitespace after ':'
Line 60:1: E303 too many blank lines (4)
Line 87:54: W292 no newline at end of file

Line 5:34: E231 missing whitespace after ':'
Line 5:39: E252 missing whitespace around parameter equals
Line 5:40: E252 missing whitespace around parameter equals
Line 22:39: E231 missing whitespace after ':'
Line 22:44: E252 missing whitespace around parameter equals
Line 22:45: E252 missing whitespace around parameter equals
Line 25:7: E111 indentation is not a multiple of four
Line 29:42: E231 missing whitespace after ':'
Line 29:47: E252 missing whitespace around parameter equals
Line 29:48: E252 missing whitespace around parameter equals
Line 32:7: E111 indentation is not a multiple of four
Line 36:77: E231 missing whitespace after ':'
Line 36:82: E252 missing whitespace around parameter equals
Line 36:83: E252 missing whitespace around parameter equals
Line 39:11: E111 indentation is not a multiple of four

Line 273:20: E231 missing whitespace after ':'
Line 274:19: E231 missing whitespace after ':'
Line 277:40: E231 missing whitespace after ':'
Line 277:63: E231 missing whitespace after ':'
Line 467:121: E501 line too long (121 > 120 characters)
Line 471:23: E231 missing whitespace after ':'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants