Repository: Cloud-CV/EvalAI
Issue: Update pagination size and add indexing
GitHub labels: enhancement

GSOC-2019

easy_to_fix

frontend

good first issue

## Current Status
We have a pagination limit of 10 currently on the frontend for `My Submission` and `View All Submissions` Page. We would like to extend this limit to 100 submissions per page. Also, we should show the submission id as well as the first column

## Deliverables
- [ ] Update pagination on `My Submissions` Page to 100
- [ ] Update pagination on `View all submissions` Page to 100
- [ ] Add the column of `Submission ID` as the left most column for both `My Submission` and `View all submissions` page

Hi, this is my first time in open source. Can I work on that?

I'd like to work on this issue if no one has been assigned yet

Hi @yashdusing Since @Niklex21 have asked first to work on this issue, hence I will give him the first priority. If he doesn't want to work on it then you are welcome to work on it.

@Niklex21 Would you like to work on the issue?

Yes, I will work on the issue. 

Thanks, @Niklex21 for confirming.
@yashdusing Please feel free to take up any other unassigned issue.

@deshraj @RishabhJain2018 Can I work on this issue?

Sure, go ahead. 

@deshraj Hey! What is `Submission ID`?

Hi, is this issue resolved? I would like to take on this issue.

Is this open?


HI @yongzx @GauravJain98 This is open. Please let us know if you would like to work on it. 

Yes I would like to work on it!

sure! you can work on it.

@yongzx Hey, are you working on it?

Yes I am working on it


@RishabhJain2018 

I couldn't understand what goes wrong for the HTTP Get request for clicking the next button when `challenge.submissionResult.next` in `ng-click=challenge.load(challenge.submissionResult.next)` shows the correct url.

I updated `app/base/utils.py` to the following to allow pagination size of 100.
```
class StandardResultSetPagination(PageNumberPagination):
    page_size = 100
    page_size_query_param = 'page_size'
    max_page_size = 1000


def paginated_queryset(queryset, request, pagination_class=StandardResultSetPagination()):
    '''
        Return a paginated result for a queryset
    '''
    paginator = pagination_class
    # paginator.page_size = settings.REST_FRAMEWORK['PAGE_SIZE']
    result_page = paginator.paginate_queryset(queryset, request)
    return (paginator, result_page)
```

I experienced this error without changing other codes:
```
django_1  | [2019-01-29 07:37:54] INFO "GET /api/jobs/challenge/1/challenge_phase/2/submission/?page=1 HTTP/1.1" 200 68893
django_1  | [2019-01-29 07:37:58] INFO "GET /api/jobs/challenge/1/challenge_phase/2/submission/?page=2 HTTP/1.1" 200 6273
django_1  | [2019-01-29 07:37:59] INFO "GET /api/jobs/challenge/1/challenge_phase/2/submission/?page=1 HTTP/1.1" 200 68886
django_1  | [2019-01-29 07:38:00] WARNING "GET /api/jobs/challenge/1/challenge_phase/2/submission/?page=11 HTTP/1.1" 404 26
```

I believe the error comes from the backend. Where should I look into to fix the error when `vm.load(url)` should be loading the correct `url` (that comes from `vm.submissionResult.next`)?

@yongzx Did you update in `settings/common.py`? You can try doing that.

@gautamjajoo @deshraj 
I managed to update the `My Submissions` and `View All Submissions` to 100 submissions per page #2054 , but may I know why I cannot pass this Travis test even though I didn't modify `apps/jobs/views.py`? 

Thank you!

```
=================================== FAILURES ===================================
 GetRemainingSubmissionTest.test_get_remaining_submission_when_submission_made_three_days_back 
self = <tests.unit.jobs.test_views.GetRemainingSubmissionTest testMethod=test_get_remaining_submission_when_submission_made_three_days_back>
    def test_get_remaining_submission_when_submission_made_three_days_back(self):
        self.url = reverse_lazy('jobs:get_remaining_submissions',
                                kwargs={
                                    'challenge_phase_pk': self.challenge_phase.pk,
                                    'challenge_pk': self.challenge.pk
                                })
        expected = {
            'remaining_submissions_today_count': 9,
            'remaining_submissions_this_month_count': 18,
            'remaining_submissions': 98
        }
    
        self.challenge.participant_teams.add(self.participant_team)
        self.challenge.save()
        self.submission1.submitted_at = timezone.now() - timedelta(days=3)
        self.submission1.save()
        response = self.client.get(self.url, {})
>       self.assertEqual(response.data, expected)
E       AssertionError: {'rem[15 chars]ons_this_month_count': 19, 'remaining_submissi[44 chars]: 98} != {'rem[15 chars]ons_today_count': 9, 'remaining_submissions_th[44 chars]: 98}
E         {'remaining_submissions': 98,
E       -  'remaining_submissions_this_month_count': 19,
E       ?                                             ^
E       
E       +  'remaining_submissions_this_month_count': 18,
E       ?                                             ^
E       
E          'remaining_submissions_today_count': 9}
tests/unit/jobs/test_views.py:580: AssertionError
```

Can I work on this issue @RishabhJain2018 @deshraj ?

Is @yongzx still working on this issue? If Yes, so sorry to interrupt your work


@kurianbenoy Please take up any other issue @yongzx has has already made a PR for it.

@kurianbenoy yes I have implemented all the features and I am just waiting for the PR to get accepted.

Closing this issue, since this is solved by #2199