diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..9de17e17 --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ +## Purpose +_Describe the problem or feature in addition to a link to the issues._ + +Example: +Fixes # . + +## Approach +_How does this change address the problem?_ + +#### 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 +- [How to Pull Request](https://github.com/flexyford/pull-request) Github Repo with Learning focused Pull Request Template. + diff --git a/applications/graphs/controllers.py b/applications/graphs/controllers.py index 7f012a05..d52f9c79 100644 --- a/applications/graphs/controllers.py +++ b/applications/graphs/controllers.py @@ -309,11 +309,11 @@ def _convert_order_query_term_to_database_order_object(order_query): def search_graphs_by_group_ids(request, group_ids=None, owner_email=None, names=None, nodes=None, edges=None, tags=None, - limit=None, offset=None): + limit=None, offset=None, order_by=None): if group_ids is None: raise Exception("Atleast one group id is required.") return db.find_graphs(request.db_session, group_ids=group_ids, owner_email=owner_email, names=names, nodes=nodes, - edges=edges, tags=tags, limit=limit, offset=offset) + edges=edges, tags=tags, limit=limit, offset=offset, order_by=order_by) def add_graph_to_group(request, group_id, graph_id): diff --git a/applications/users/controllers.py b/applications/users/controllers.py index be2fe623..15e0f581 100644 --- a/applications/users/controllers.py +++ b/applications/users/controllers.py @@ -266,8 +266,10 @@ def delete_group_member(request, group_id, member_id): db.delete_group_to_user(request.db_session, group_id=group_id, user_id=member_id) return +def search_group_graphs(request, group_id, owner_email, names=None, nodes=None, edges=None, limit=20, offset=0, order='asc', sort='name'): + sort_attr = getattr(db.Graph, sort if sort is not None else 'name') + orber_by = getattr(db, order if order is not None else 'desc')(sort_attr) -def search_group_graphs(request, group_id, owner_email, names=None, nodes=None, edges=None, limit=20, offset=0): total, group_graphs = graphs.controllers.search_graphs_by_group_ids(request, group_ids=[group_id], owner_email=owner_email, @@ -275,7 +277,8 @@ def search_group_graphs(request, group_id, owner_email, names=None, nodes=None, nodes=nodes, edges=edges, limit=limit, - offset=offset) + offset=offset, + order_by=orber_by) return total, group_graphs diff --git a/applications/users/views.py b/applications/users/views.py index ccc0cd6e..488356b8 100644 --- a/applications/users/views.py +++ b/applications/users/views.py @@ -751,6 +751,10 @@ def _get_group_graphs(request, group_id): Search for graphs with the given node names. In order to search for graphs with either of the given node names as a substring, wrap the node name with percentage symbol. For example, %xyz% will search for all graphs with xyz in their node names. edges : list of strings Search for graphs with the given edges. An edge can be represented as :. In order to perform a substring on edges, wrap the node names with percentage symbol. For example, %xyz%:%abc% will search for all graphs with edges between nodes with xyz in their node names to nodes with abc in their node name. + order : string + Defines the column sort order, can only be 'asc' or 'desc'. + sort : string + Defines which column will be sorted. Parameters ---------- @@ -785,7 +789,10 @@ def _get_group_graphs(request, group_id): nodes=nodes if nodes is None or isinstance(nodes, list) else [nodes], edges=edges if edges is None or isinstance(edges, list) else [edges], limit=request.GET.get('limit', 20), - offset=request.GET.get('offset', 0)) + offset=request.GET.get('offset', 0), + order=request.GET.get('order', 'asc'), + sort=request.GET.get('sort', 'name') + ) return { 'total': total,