From f461e4f29a8f32ec954cf858fb21de936f3b325b Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 7 Oct 2024 15:54:33 -0500 Subject: linting: Fix minor linting issues. --- uploader/samples/views.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'uploader/samples/views.py') diff --git a/uploader/samples/views.py b/uploader/samples/views.py index 9ba1df8..b8ec4d4 100644 --- a/uploader/samples/views.py +++ b/uploader/samples/views.py @@ -3,11 +3,8 @@ import os import sys import uuid from pathlib import Path -from typing import Iterator -import MySQLdb as mdb from redis import Redis -from MySQLdb.cursors import DictCursor from flask import (flash, request, url_for, @@ -20,11 +17,11 @@ from uploader.files import save_file from uploader.ui import make_template_renderer from uploader.authorisation import require_login from uploader.input_validation import is_integer_input -from uploader.datautils import order_by_family, enumerate_sequence -from uploader.db_utils import ( - with_db_connection, - database_connection, - with_redis_connection) +from uploader.datautils import safe_int, order_by_family, enumerate_sequence +from uploader.population.models import population_by_id, populations_by_species +from uploader.db_utils import (with_db_connection, + database_connection, + with_redis_connection) from uploader.species.models import (all_species, species_by_id, order_species_by_family) @@ -110,9 +107,7 @@ def list_samples(species_id: int, population_id: int): all_samples = enumerate_sequence(samples_by_species_and_population( conn, species_id, population_id)) total_samples = len(all_samples) - offset = int(request.args.get("from") or 0) - if offset < 0: - offset = 0 + offset = max(safe_int(request.args.get("from") or 0), 0) count = int(request.args.get("count") or 20) return render_template("samples/list-samples.html", species=species, -- cgit v1.2.3