-
Notifications
You must be signed in to change notification settings - Fork 4
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
function added to print paths from source to destination with the shortest number of link #29
base: master
Are you sure you want to change the base?
Conversation
Hi, have you reviewed the code yet? Please let me know if anything needs to be done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pull requests, please see the comments below
@@ -525,3 +570,26 @@ def _insert_link(session, from_page_id, to_page_id, no_of_separation): | |||
"Many rows found in DB to store link from {} to {}\ | |||
with number of seperation {}".format(from_page_id, to_page_id, | |||
no_of_separation)) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So by convention, we separate 2 functions by 2 empty lines
def get_url_path_from_page_ids(session, page_ids_list): | ||
path_url = [] | ||
for page_id in page_ids_list: | ||
page_url = session.query(Page).filter(Page.id == page_id).first() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For DB operation, please consider to add try/except, i.e. in case DB connection failure
successful_paths = [] | ||
|
||
with self._session_scope() as session: | ||
def find_route_to_parent(node, source_root_id, depth=0, session=session): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what happens if 2 links are parents of each other, i.e. url of 1 can be found from the other wiki page and vice versal; this will create an infinite loop and running out of limit soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are having check on the depth with limit.
Added function _print_path to print path from source to destination.
The logic used is to backtrack from destination id to source id and print the shortest path.