1
00:00:00,180 --> 00:00:00,540
All right.

2
00:00:00,810 --> 00:00:07,740
We're almost almost almost one setting up the functionality on the server when it comes to pagination.

3
00:00:08,220 --> 00:00:13,500
The only thing that is missing right now is the correct value for total jobs.

4
00:00:14,070 --> 00:00:20,670
And we're also not displaying how many pages we have in total because this is very important for us

5
00:00:21,090 --> 00:00:25,560
on the frontend on first, Oatman showcase the total jobs issue.

6
00:00:25,890 --> 00:00:29,040
We're at the moment we're relying on jobs, not length.

7
00:00:30,090 --> 00:00:35,100
But keep in mind that in order to get the jobs, we already used the limit and where I'm going with

8
00:00:35,100 --> 00:00:40,720
this is the fact that total jobs will always reflect the limit in our current set up.

9
00:00:40,740 --> 00:00:46,880
So if I'm going to go here with 10, if I'll send it, I'm going to get back total jobs then and then

10
00:00:46,890 --> 00:00:52,050
if I'll change this around to 25, you can already guess that this value will be 25.

11
00:00:52,590 --> 00:00:53,410
And what is the problem?

12
00:00:53,490 --> 00:01:01,920
Well, on a front end, I actually want to showcase how many total jobs I got with this query, because

13
00:01:01,920 --> 00:01:06,130
at the moment I'm just displaying how many jobs per page I'm displaying.

14
00:01:06,480 --> 00:01:07,620
And that's not what I want.

15
00:01:08,130 --> 00:01:11,340
And the second thing is, like I said, number of pages.

16
00:01:12,240 --> 00:01:18,540
So how many pages we have total because that's going to be very nifty for us when we set up our button

17
00:01:18,540 --> 00:01:19,020
container.

18
00:01:19,550 --> 00:01:20,940
And in order to fix that.

19
00:01:21,860 --> 00:01:28,640
Here's what we're going to do after we await the result, set up another await, and in this case,

20
00:01:28,640 --> 00:01:31,970
we're going to go with the job, then count documents.

21
00:01:32,300 --> 00:01:33,050
That's the method.

22
00:01:33,650 --> 00:01:39,650
And essentially, this method counts the documents, but I don't want to count all the job documents.

23
00:01:40,250 --> 00:01:44,420
And what's really cool actually can pass in the same query object.

24
00:01:45,290 --> 00:01:47,000
So in this case, I'm just getting back.

25
00:01:47,330 --> 00:01:51,440
Well, how many total jobs I have for that specific query.

26
00:01:51,920 --> 00:01:53,540
So that's going to get me the total jobs.

27
00:01:53,690 --> 00:01:57,770
And in this case, it's not going to be relying on the limit, it's going to be independent.

28
00:01:58,130 --> 00:02:04,460
And when it comes to number of pages, I'm going to go with the math that ceiling because we'll always

29
00:02:04,480 --> 00:02:09,560
rounded up and will divide total jobs by the limit we have.

30
00:02:10,280 --> 00:02:12,200
So let's say I have 75 jobs.

31
00:02:12,560 --> 00:02:16,280
I'll divide this by 10, which is my limit, my default one.

32
00:02:16,910 --> 00:02:20,030
And that will give me 7.5 pages.

33
00:02:20,090 --> 00:02:22,400
Now, I don't want to displace 7.5.

34
00:02:22,790 --> 00:02:29,630
I actually went around it up because I'll have seven pages would find jobs among the eighth one is going

35
00:02:29,630 --> 00:02:31,580
to have the remaining jobs.

36
00:02:31,970 --> 00:02:35,060
In my case, five of us makes sense.

37
00:02:35,510 --> 00:02:40,430
So let's go to a jobs controller and let's set up both of those things.

38
00:02:40,880 --> 00:02:46,070
So first, we want to go with Konst Total and then jobs and not as equal to 08.

39
00:02:46,460 --> 00:02:48,800
But again, we go with our model.

40
00:02:48,920 --> 00:02:50,420
The job model than that.

41
00:02:51,140 --> 00:02:57,460
And then, like I said, the method name is count documents and we just want to pass in the query object.

42
00:02:58,050 --> 00:03:04,490
One, let's count the number of pages and we're going to do that by again, math that ceiling and then

43
00:03:04,490 --> 00:03:07,070
we'll divide total jobs by the element.

44
00:03:07,280 --> 00:03:13,460
So let's go here with number of pages than let's use the math that ceiling.

45
00:03:13,820 --> 00:03:18,020
And let's pass in total jobs divided by the limit.

46
00:03:18,140 --> 00:03:20,110
Now I just need to fix our third one.

47
00:03:20,510 --> 00:03:23,660
The old jobs is not going to equal to a jobs, not length.

48
00:03:23,960 --> 00:03:28,550
Again, jobs length is actually being controlled right now with a limit.

49
00:03:29,150 --> 00:03:30,230
So it's remove it.

50
00:03:30,680 --> 00:03:34,130
And instead of hard coding that one, we're going to go with.

51
00:03:34,520 --> 00:03:39,200
Number of pages, essentially, we'll set it equal to this variable.

52
00:03:39,620 --> 00:03:46,220
And once we say right now, you'll notice that regardless of what is the limit over here, actually

53
00:03:46,220 --> 00:03:48,200
get total jobs correctly.

54
00:03:48,470 --> 00:03:50,840
So this is going to be certified and check it out.

55
00:03:51,350 --> 00:03:57,470
What we're controlling with the limit right now is the number of pages, but total jobs won't change.

56
00:03:57,470 --> 00:04:00,830
So if I'll change this one to 25, you'll notice.

57
00:04:01,190 --> 00:04:08,270
But I'll have three total pages because again, our total job is going to be 75 divided by the 25,

58
00:04:08,330 --> 00:04:09,290
which is going to be three.

59
00:04:09,650 --> 00:04:15,110
But this one will always stay 75 knots, the look that I want on the front end.

60
00:04:15,410 --> 00:04:19,820
And with this in place now, I can start setting up the frontend functionality.

