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

Added sort functionality (wikimedia hackathon contribution) #14

Closed
wants to merge 4 commits into from

Conversation

hks3333
Copy link

@hks3333 hks3333 commented May 25, 2024

Added sort option above the table, now the data can be sorted on the basis of tool title/author.

Updated README.

image

was_crawled = []
for tool in paginated_tools:
url_parsed = urlparse(tool.url)
if url_parsed.hostname != None and 'toolforge.org' in url_parsed.hostname :
Copy link
Owner

@gopavasanth gopavasanth May 26, 2024

Choose a reason for hiding this comment

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

Modularise code, something similar to:

def get_paginated_tools(session, order_by, curr_page):
tools = session.query(Tool).order_by(order_by).all()
total_pages = (len(tools) + page_limit - 1) // page_limit
paginated_tools = tools[(curr_page - 1) * page_limit:curr_page * page_limit]
was_crawled = [urlparse(tool.url).hostname and 'toolforge.org' in urlparse(tool.url).hostname for tool in paginated_tools]
return paginated_tools, was_crawled, total_pages

@app.route("/sortT")
def sortT():
session = Session()
curr_page = int(request.args.get("page", 1))
paginated_tools, was_crawled, total_pages = get_paginated_tools(session, Tool.title, curr_page)
return render_template('index.html', tools=paginated_tools, was_crawled=was_crawled, curr_page=curr_page, total_pages=total_pages, route='sortT')

@app.route("/sortA")
def sortA():
session = Session()
curr_page = int(request.args.get("page", 1))
paginated_tools, was_crawled, total_pages = get_paginated_tools(session, Tool.author, curr_page)
return render_template('index.html', tools=paginated_tools, was_crawled=was_crawled, curr_page=curr_page, total_pages=total_pages, route='sortA')

@gopavasanth
Copy link
Owner

Also, it would be helpful to achieve sort behaviours of the table something similar to https://vuetifyjs.com/en/components/data-tables/basics/#usage

That means sort items based on click of table header.

@hks3333
Copy link
Author

hks3333 commented May 27, 2024

We are doing some modifications, you can expect a pr soon. Closing this pr for now.

@hks3333 hks3333 closed this May 27, 2024
@varun-s22
Copy link
Collaborator

Just a quick follow up here.
Can we please add sort by health as well

cc @gopavasanth @hks3333

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.

4 participants