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

Fork functionality #385

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

Conversation

jahandaniyal
Copy link
Collaborator

@jahandaniyal jahandaniyal commented May 19, 2018

Purpose

This patch fixes #336 - Allow users to fork/clone a graph.

Feature Details

  1. Fork Graph Tab is not visible for Anonymous Users.
  2. There is a separate tab available to Signed-in Users for viewing Forked Graphs.
  3. Signed-in User can Fork all Public graphs and graph(s) shared with them in some group(s).
  4. User can choose a name for the forked graph or leave the name field empty to use the default name.
  5. Notification of successful fork and error both displayed in the Graph page.
  6. Deleting a particular Forked graph will remove its parent-to-fork graph relationship entry from the database.
  7. Deleting a Parent Graph will remove all parent-to-fork graph(s) relationship entries from the database. The Forked graphs will now behave just like Owned Graphs.
  • Changes in the Database : Added graph_fork_table with the following fields - graph_id, and parent_graph_id.

Approach

Forking option is only available for public and shared graphs not owned by the current User.
I have created the Fork REST Api to handle Forking requests. User can send an add fork request using the Fork POST method. Graph details and JSON data is passed along with the request body. I am checking for user authentication and allowing only GET and POST requests from the user.
For saving a fork I am using the following approach :
From the request body I extract and store the ID of the graph as parent_graph_id, then I create a new graph using the existing add_graph functionality. When a new graph has been created I will insert a record in the graph_fork table with the graph_id of the new graph just created and the parent_graph_id.

Populating Index Page tables :
Forked Graph index page is populated in a way similar to Public Graphs. Index pages of all graphs are populated using the Graph search feature, for example, in case of public graphs parameter is_public is passed to the search function. For forked graphs I am using the parameter is_forked. I have used this approach because a forked graph can also be considered as an Owned Graph therefore it needs a way to be found using the Graph API's search endpoint.

TEST CASES

  1. Try to Fork public/shared graph.
    Observation : Works without any issues.
  2. Forked Graph Tab.
    Observation : Forked graph tab is not visible for anonymous users. It is visible only for signed-in users
  3. Forked Graph table
    Observation : Shows the forked graphs list correctly in the UI.
  4. Delete a Forked Graph
    Observation : The graph is removed from the database and Owned/Forked Graph table. parent_to_fork entry is erased from graph_fork table in the database.
  5. Delete a Parent Graph
    Observation : Parent Graph is removed from the database. All parent_to_fork entries are erased from graph_fork table in the database. This operations does not remove the Forked Graphs from the database, it only erases the parent_to_fork relationship information.
  6. Fork Button Behavior
    Observation : Displays the number of times the Parent Graph has been forked (Pending). Hidden for all Owned/Private Graphs. Disabled after a successful Fork operation.

ezgif-3-3900458602

Open Questions and Pre-Merge TODOs

  • Use github checklists. When solved, check the box and explain the answer.

Learning

Describe the research stage

Links to blog posts, patterns, libraries or addons used to solve this problem

Blog Posts

adbharadwaj and others added 5 commits March 3, 2018 20:36
Adding a pull request template to standardize the description of the proposed changes from contributors. Project contributors will automatically see the template's contents in the pull request body.

More details can be found [here](https://help.github.com/articles/creating-a-pull-request-template-for-your-repository/).
Copy link
Collaborator

@adbharadwaj adbharadwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a documentation of how the forked graphs API request and response will look like. Make changes here - https://github.com/Murali-group/GraphSpace/blob/master/api_specifications/api.raml

Use some RAML editor. In the past, we have used API Workbench

You are also missing User documentation. I will not be able to pull the request unless you submit the User documentation.

@@ -333,10 +333,11 @@ def delete_graph_to_group(request, group_id, graph_id):


def search_graphs1(request, owner_email=None, names=None, nodes=None, edges=None, tags=None, member_email=None,
is_public=None, query=None, limit=20, offset=0, order='desc', sort='name'):
is_public=None, is_forked=None, query=None, limit=20, offset=0, order='desc', sort='name'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure you are using pycharm editor and running auto formatting before committing the code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into this issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Followed PEP8 conventions for all python codes.

@@ -362,6 +363,7 @@ def search_graphs1(request, owner_email=None, names=None, nodes=None, edges=None
owner_email=owner_email,
graph_ids=graph_ids,
is_public=is_public,
is_forked=is_forked,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting doesnt look right.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing it now.

def add_fork(db_session, forked_graph_id, parent_graph_id, owner_email):
fork = GraphFork( graph_id=forked_graph_id, parent_graph_id=parent_graph_id, owner_email=owner_email)
db_session.add(fork)
return 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return fork object. Refer to other functions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add python docs. Refer to other functions.



def upgrade():
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add table.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing it.

@jahandaniyal
Copy link
Collaborator Author

Forked GraphSpace Manual repo and installed API Workbench on Atom.
Will build GraphSpace Manual right now and add the documentation for both PRs immediately.

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