Skip to content

Commit 69008a4

Browse files
authored
Merge pull request #31 from TAMULib/sprint3-staging-post-sprint-requests
Sprint3 staging post sprint requests
2 parents ca05aae + 0f004f0 commit 69008a4

9 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/main/java/edu/tamu/app/controller/NoteController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public ApiResponse remove(@ApiValidatedModel Note note) {
6464
@ApiMapping("/page")
6565
@Auth(role = "ROLE_ANONYMOUS")
6666
public ApiResponse page(@ApiData FilteredPageRequest filteredPageRequest) {
67-
return new ApiResponse(SUCCESS, noteRepo.findAllByOrderByLastModifiedDesc(filteredPageRequest.getPageRequest()));
67+
return new ApiResponse(SUCCESS, noteRepo.findAllByOrderByServiceNameAscLastModifiedDesc(filteredPageRequest.getPageRequest()));
6868
}
6969

7070
}

src/main/java/edu/tamu/app/controller/ServiceController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public class ServiceController {
3131
@ApiMapping("/all")
3232
@Auth(role = "ROLE_ANONYMOUS")
3333
public ApiResponse getAllServices() {
34-
return new ApiResponse(SUCCESS, serviceRepo.findAllByOrderByIdDesc());
34+
return new ApiResponse(SUCCESS, serviceRepo.findAllByOrderByStatusDescNameAsc());
3535
}
3636

3737
@ApiMapping("/public")
3838
@Auth(role = "ROLE_ANONYMOUS")
3939
public ApiResponse getPublicServices() {
40-
return new ApiResponse(SUCCESS, serviceRepo.findByIsPublicOrderByIdDesc(true));
40+
return new ApiResponse(SUCCESS, serviceRepo.findByIsPublicOrderByStatusDescNameAsc(true));
4141
}
4242

4343
@ApiMapping("/{id}")

src/main/java/edu/tamu/app/enums/NotificationLocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public enum NotificationLocation {
44

5-
MAIN, CUSHING, MSL, WCL, PSEL, QATAR;
5+
MAIN, EVANS, CUSHING, MSL, WCL, PSEL, QATAR;
66

77
}

src/main/java/edu/tamu/app/enums/Status.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public enum Status {
44

5-
UP, DOWN, MAINTENANCE;
5+
UP, MAINTENANCE, DOWN;
66

77
}

src/main/java/edu/tamu/app/model/repo/NoteRepo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface NoteRepo extends JpaRepository<Note, Long>, NoteRepoCustom, Jpa
1515

1616
public Page<Note> findAll(Specification<Note> specification, Pageable pageable);
1717

18-
public Page<Note> findAllByOrderByLastModifiedDesc(Pageable pageable);
18+
public Page<Note> findAllByOrderByServiceNameAscLastModifiedDesc(Pageable pageable);
1919

2020
public List<Note> findAllByServiceId(Long id);
2121

src/main/java/edu/tamu/app/model/repo/ServiceRepo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
public interface ServiceRepo extends JpaRepository<Service, Long>, ServiceRepoCustom {
1212

13-
public List<Service> findByIsPublicOrderByIdDesc(Boolean isPublic);
13+
public List<Service> findByIsPublicOrderByStatusDescNameAsc(Boolean isPublic);
1414

1515
public List<Service> findByIsAuto(Boolean isAuto);
1616

17-
public List<Service> findAllByOrderByIdDesc();
17+
public List<Service> findAllByOrderByStatusDescNameAsc();
1818

1919
public Long countByStatus(Status status);
2020

src/main/java/edu/tamu/app/model/request/FilteredPageRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public NoteSpecification<Note> getSpecification() {
3434

3535
@JsonIgnore
3636
public PageRequest getPageRequest() {
37-
return new PageRequest(pageNumber - 1, pageSize, new Sort(Sort.Direction.fromString(direction), properties));
37+
return new PageRequest(pageNumber > 0 ? pageNumber - 1 : 0, pageSize > 0 ? pageSize : 10, new Sort(Sort.Direction.fromString(direction), properties));
3838
}
3939

4040
public int getPageNumber() {

src/main/java/edu/tamu/app/service/OverallStatusService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void updateStatuses() {
4343
}
4444
}
4545

46-
for (edu.tamu.app.model.Service service : serviceRepo.findByIsPublicOrderByIdDesc(true)) {
46+
for (edu.tamu.app.model.Service service : serviceRepo.findByIsPublicOrderByStatusDescNameAsc(true)) {
4747
if (service.getStatus().equals(Status.DOWN)) {
4848
publicServicesAreUp = false;
4949
break;

src/test/java/controller/ServiceControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public void setUp() {
8181
when(credentials.getUin()).thenReturn("123456789");
8282
when(userRepo.findByUin(any(String.class))).thenReturn(user);
8383
when(systemMonitorService.getOverallStatus()).thenReturn(new OverallStatus(edu.tamu.app.enums.OverallMessageType.SUCCESS, "Success"));
84-
when(serviceRepo.findAllByOrderByIdDesc()).thenReturn(mockServiceList);
85-
when(serviceRepo.findByIsPublicOrderByIdDesc(true)).thenReturn(mockPublicServiceList);
84+
when(serviceRepo.findAllByOrderByStatusDescNameAsc()).thenReturn(mockServiceList);
85+
when(serviceRepo.findByIsPublicOrderByStatusDescNameAsc(true)).thenReturn(mockPublicServiceList);
8686
when(serviceRepo.findOne(any(Long.class))).thenReturn(TEST_SERVICE1);
8787
when(serviceRepo.create(any(Service.class))).thenReturn(TEST_SERVICE1);
8888
when(serviceRepo.update(any(Service.class))).thenReturn(TEST_MODIFIED_SERVICE1);

0 commit comments

Comments
 (0)