-
Notifications
You must be signed in to change notification settings - Fork 221
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
Support pagination in sessions listing API #1173
Conversation
I also created an image to show the loading when fetching sessions. Please check this too and compare which looks better. |
Hello, @tosametal Thank you for creating this PR. Does the difference between If so, I like Loading version. I confirmed the following steps. no loading version
Loading version
|
@hiroyuki-sato Thank you for confirmation.
Yes, that's the only difference.
OK. I will add a commit that shows the loading image to this PR. When the number of pages is more than 10, the button display changes. Please try it. |
Hello, @tosametal This is just my(not committer) opinion. |
Hello, @tosametal
It seems to work well.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. I took a brief look.
Please check the comments.
Current implementation will cause problem in large use case.
In addition please take care of API compatibility, method signature of common classes as much as possible.
digdag-core/src/main/java/io/digdag/core/database/DatabaseSessionStoreManager.java
Outdated
Show resolved
Hide resolved
digdag-server/src/main/java/io/digdag/server/rs/ProjectResource.java
Outdated
Show resolved
Hide resolved
digdag-server/src/main/java/io/digdag/server/rs/ProjectResource.java
Outdated
Show resolved
Hide resolved
In addition I propose split this ticket to UI part and API part for our review. |
@hiroyuki-sato Thank you for confirmation. I confirmed it as follows. # sample1.dig
timezone: 'Asia/Tokyo'
schedule:
minutes_interval>: 1
+task:
sh>: echo hoge for i in `seq 2 100`
do
cp sample1.dig sample$i.dig
done digdag push project -e http://localhost:65432 and wait 10 minutes... |
@yoyama Thank you for your review. I will check the comments and fix them.
Does this mean I should close this PR and create two new PRs? |
@tosametal You don't need to close this PR. |
@yoyama I agree with your suggestion.I will do that. |
@tosametal If you finished update, please ping me. |
@tosametal Thanks for you fix. I will check it later. |
I updated the title. I misunderstood this PR. |
|
||
return RestModels.sessionCollection(rs, sessions); | ||
Integer page = Optional.fromNullable(pageNumber).or(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name page is uncertain.
It may be better to define QueryParamValidator.validatePageNumber and change the name to validPageNumber.
@@ -64,17 +65,20 @@ public SessionResource( | |||
@Path("/api/sessions") | |||
public RestSessionCollection getSessions( | |||
@QueryParam("last_id") Long lastId, | |||
@QueryParam("page_size") Integer pageSize) | |||
@QueryParam("page_size") Integer pageSize, | |||
@QueryParam("page_number") Integer pageNumber) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed if page_number <=0, API become error in SQL execution.
I guess it is better to validate before execute query.
But page_size is also same behavior.
It is not mandatory and another PR which fix both page_size and page_number may be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will fix the problem in another PR.
@@ -425,15 +427,18 @@ public RestSessionCollection getSessions( | |||
SessionStore ss = ssm.getSessionStore(getSiteId()); | |||
|
|||
StoredProject proj = ensureNotDeletedProject(ps.getProjectById(projectId)); | |||
Integer page = Optional.fromNullable(pageNumber).or(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as SessionResource. Please change var name.
} | ||
|
||
@Override | ||
public Integer getTotalSessionsCount(Optional<Long> lastId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSessionsCount may be better name.
} | ||
|
||
@Override | ||
public Integer getTotalProjectSessionsCount(Optional<Long> lastId, int projectId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSessionsCountOfProject may be better to fit getSessionsOfProject.
@yoyama I added validatePageNumber to QueryParamValidator and fixed variable and method name.Please check it. |
@tosametal Sorry for my late response. |
} | ||
|
||
@Override | ||
public List<StoredSessionWithLastAttempt> getSessions(int pageSize, Optional<Long> lastId, int pageNumber) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess switch the order of pageNumber and lastId may be understandable.
Other method also same.
" join session_attempts sa on sa.id = s.last_attempt_id" + | ||
" where s.project_id = :projectId" + | ||
" and s.id < :lastId") | ||
Integer getSessionsCountOfProject(@Bind("lastId") long lastId, @Bind("projectId") int projectId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this query is different from getSessionsOfProject. Not have site_id condition.
Could you fix it and add test code for *Count() method.
In addition the test data should include different site_id and check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tosametal Sorry for my late response. I made some comments to your code. please check and fix them.
@yoyama Sorry for my too late response. I fixed the below.Please check them.
|
@tosametal I would like to close this ticket once because it is too old and code is conflicted and we are working on v0.10.0 release. |
Support pagination on WorkflowsPage, ProjectsPage and ProjectPage(#1106 is related)
I made the docker image, so you can check the ui with the following command.
→ access to http://localhost:65432