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

function added to print paths from source to destination with the shortest number of link #29

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pradeepjnayak
Copy link

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.

@pradeepjnayak
Copy link
Author

Hi, have you reviewed the code yet? Please let me know if anything needs to be done

@tranlv tranlv self-requested a review July 10, 2019 15:50
wikilink/wiki_link.py Outdated Show resolved Hide resolved
Copy link
Owner

@tranlv tranlv left a 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

wikilink/wiki_link.py Show resolved Hide resolved
@@ -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))

Copy link
Owner

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

wikilink/wiki_link.py Show resolved Hide resolved
wikilink/wiki_link.py Outdated Show resolved Hide resolved
wikilink/wiki_link.py Outdated Show resolved Hide resolved
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()
Copy link
Owner

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):
Copy link
Owner

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

Copy link
Author

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.

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

Successfully merging this pull request may close these issues.

2 participants