| 624 | |
| 625 | @staticmethod |
| 626 | def list(session, |
| 627 | task_ids = None, |
| 628 | status = None, |
| 629 | date_from = None, |
| 630 | date_to = None, |
| 631 | job_id = None, |
| 632 | job_id_list = None, |
| 633 | incoming_directory_id = None, |
| 634 | file_id = None, |
| 635 | project_id = None, |
| 636 | mode_data = None, |
| 637 | issues_filter = None, |
| 638 | return_mode = None, |
| 639 | limit_count = 25, |
| 640 | page_number = 0 # 0 is same as no offset |
| 641 | ): |
| 642 | query = session.query(Task) |
| 643 | if task_ids: |
| 644 | query = query.filter( |
| 645 | Task.id.in_(task_ids) |
| 646 | ) |
| 647 | if status and status != 'all': |
| 648 | query = query.filter( |
| 649 | Task.status == status |
| 650 | ) |
| 651 | elif status == 'all': |
| 652 | query = query.filter( |
| 653 | Task.status != 'archived' |
| 654 | ) |
| 655 | else: |
| 656 | query = query.filter( |
| 657 | Task.status != 'archived' |
| 658 | ) |
| 659 | if incoming_directory_id: |
| 660 | query = query.filter(Task.incoming_directory_id == incoming_directory_id) |
| 661 | |
| 662 | if job_id_list: |
| 663 | query = query.filter(Task.job_id.in_(job_id_list)) |
| 664 | |
| 665 | if job_id: |
| 666 | query = query.filter(Task.job_id == job_id) |
| 667 | |
| 668 | if mode_data == "exam_results": |
| 669 | # Only show review tasks since this is what would count here? |
| 670 | # QUESTION do we want to have the job type check here too |
| 671 | # query = query.filter(Task.task_type == "review", Task.job_type == "Exam") |
| 672 | |
| 673 | # WIP with auto grader, reviews may just be posted on original tasks. |
| 674 | query = query.filter(Task.job_type == "Exam") |
| 675 | |
| 676 | if date_from: |
| 677 | date_from = datetime.datetime.strptime(date_from, "%Y-%m-%d") |
| 678 | query = query.filter(Task.time_updated >= date_from) |
| 679 | if date_to: |
| 680 | date_to = datetime.datetime.strptime(date_to, "%Y-%m-%d") |
| 681 | query = query.filter(Task.time_updated <= date_to) |
| 682 | |
| 683 | if file_id: |