-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add filters for projects #14
base: master
Are you sure you want to change the base?
Conversation
POSTGRES_PASSWORD: 1234 | ||
POSTGRES_DB: postgres | ||
ports: | ||
- 5440:5432 |
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.
why did you add docker configuration? And how should app be launched now?
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.
This is just the configuration for the database. If you don't want to use it, launching the application will be the same.
I added it because I don't want to touch the local database, so I created a docker file for this project. This is useful if you don't have postgres on your computer or don't want to touch it, it will be an isolated, clean database every time you run the container(but when app is launched seeding with liquibase still works for docker DB).
|
||
public interface ProjectService { | ||
Iterable<ProjectTO> findAll(); | ||
ProjectTO findById(long id); | ||
ProjectTO addProject(ProjectRequestTO project); | ||
List<ProjectTO> findProjectsBetweenDates(Date startDate, Date endDate); |
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.
Make return parameter Iterable<ProjectTO>
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.
Fix comments
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.
You need to fix all the problems. It would also be very cool if you could tell me what filters you need in the end, point by point, and need to implement all of them to merge into the master later. At the moment I can't start the server
@GetMapping | ||
public Iterable<ProjectTO> getAllProjects() { | ||
return projectService.findAll(); | ||
@GetMapping("/projects") |
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.
There is path /data/projects already in @RequestMapping and it will be added to all paths, so do not add /projects to your @GetMapping. Now your path looks like this: loacalhost:8080/data/projects/projects
return projectService.findAll(); | ||
@GetMapping("/projects") | ||
public List<ProjectTO> getProjectsBetweenDates( | ||
@RequestParam("startDate") @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate, |
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.
If you delete get request with all project, most likely it should be that your query should output all projects if there are no parameters, but your parameters are required, and nowhere is it checked for their null. To do this, you can use Optional and in service check for null
public Iterable<ProjectTO> getAllProjects() { | ||
return projectService.findAll(); | ||
@GetMapping("/projects") | ||
public List<ProjectTO> getProjectsBetweenDates( |
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.
You must do only filter by date?
|
||
|
||
@Query("SELECT p FROM public.Project as p, Tag as pt WHERE pt.tag_id = :tagID AND p.id = pt.project_id AND p.start > :startDate AND (p.end IS NULL OR p.end <= :endDate)") | ||
List<Project> findProjectsBetweenDates(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("tagID") Integer tagID); |
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.
Why you use here tagId and its Integer? And in the service, when you call this function, do not write any tagId, I get an error because of this
|
||
|
||
@Query("SELECT p FROM public.Project as p, Tag as pt WHERE pt.tag_id = :tagID AND p.id = pt.project_id AND p.start > :startDate AND (p.end IS NULL OR p.end <= :endDate)") | ||
List<Project> findProjectsBetweenDates(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("tagID") Integer tagID); |
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.
Also I could not start the server because the request was not written correctly
@@ -72,6 +73,12 @@ public ProjectTO addProject(ProjectRequestTO projectRequest) { | |||
return ConvertToTO.projectToTO(project); | |||
} | |||
|
|||
@Override | |||
public List<ProjectTO> findProjectsBetweenDates(java.util.Date startDate, java.util.Date endDate) { |
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.
You need to make java.util.Date import
@@ -1,4 +1,4 @@ | |||
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres?useSSL=false | |||
spring.datasource.url=jdbc:postgresql://localhost:5440/postgres?useSSL=false |
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.
Why you change port? If you use a docker, it is better to keep it on your computer, so that there will be no problems when they merge the branch into the master
@@ -1,6 +1,6 @@ | |||
classpath= | |||
changeLogfile=db/changelog/db.changelog-master.xml | |||
url=jdbc:postgresql://localhost:5432/postgres?useSSL=false | |||
url=jdbc:postgresql://localhost:5440/postgres?useSSL=false |
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.
Here the same problem as in src/main/resources/application.properties
@End-rey, @SerjVankovich, can you please help me resolve the 3rd merge conflict? |
@RequestParam(required = false, defaultValue = "[]") List<String> tags_from_request, | ||
@RequestParam(required = false, defaultValue = "[]") List<String> clinics_from_request) { | ||
return projectService.getProjects(string_to_search, startDate, endDate, sorting_by_Date, tags_from_request, | ||
clinics_from_request); |
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.
Consider to use camelCase instead of snake_case.
|
||
public interface ProjectRepo extends JpaRepository<Project, Long> { | ||
|
||
|
||
// WHERE cast(p.id as text) LIKE %:string_to_search%"' |
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.
Remove comment
I don't know why, but when i search by first word in description it doesn't work |
"CASE WHEN :sorting_by_Date = 'ASC' THEN p.start END ASC, " + | ||
"CASE WHEN :sorting_by_Date = 'DESC' THEN p.start END DESC, " + | ||
"CASE WHEN :sorting_by_Date = 'NULL' THEN NULL END") | ||
// "AND (t.name IN (:tags_from_request)) ") |
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.
Remove comment
@Override | ||
public Iterable<ProjectTO> getProjects(String string_to_search, Date startDate, Date endDate, Sort sorting_by_Date, | ||
List<String> tags_from_request, List<String> clinics_from_request) { | ||
// System.out.println(projectRepo.getProjectsByFilters()); |
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.
Remove comment
Search by supervisor does not work |
I think I figured out what the problem is. The search does not work if the word you want to find has a capital letter. |
The filter does not work when I enter a tag list:
|
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.
Fix comments
It is not very clear how the filter by date works. In theory, when I search by startDate should display projects exactly for the specified year and no more, the same with endDate - only projects that end in the specified year |
Pull request