Skip to content

Commit 70bda2f

Browse files
committed
order of notes, notifications, and service
1 parent 6ebf3d2 commit 70bda2f

16 files changed

Lines changed: 32 additions & 15 deletions

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.findAll(filteredPageRequest.getPageRequest()));
67+
return new ApiResponse(SUCCESS, noteRepo.findAllByOrderByLastModifiedDesc(filteredPageRequest.getPageRequest()));
6868
}
6969

7070
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class NotificationController {
3434
@ApiMapping("/all")
3535
@Auth(role = "ROLE_STAFF")
3636
public ApiResponse getAllNotifications() {
37-
return new ApiResponse(SUCCESS, notificationRepo.findAll());
37+
return new ApiResponse(SUCCESS, notificationRepo.findAllByOrderByIdDesc());
3838
}
3939

4040
@ApiMapping("/{id}")

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.findAll());
34+
return new ApiResponse(SUCCESS, serviceRepo.findAllByOrderByIdDesc());
3535
}
3636

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

4343
@ApiMapping("/{id}")

src/main/java/edu/tamu/app/job/ProcessSchedules.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class ProcessSchedules {
3535
@Autowired
3636
private SimpMessagingTemplate simpMessagingTemplate;
3737

38-
@Scheduled(cron = "5 0/5 * * * ?")
38+
@Scheduled(cron = "5 0/1 * * * ?")
3939
private void checkSchedules() {
4040

4141
Date date = new Date();
@@ -48,6 +48,9 @@ private void checkSchedules() {
4848
scheduler.setWithinSchedule(false);
4949
scheduler = abstractSchedulerRepo.save(scheduler);
5050
logger.info("Ending schedule for " + scheduler);
51+
scheduler.removeSchedule(schedule);
52+
scheduler = abstractSchedulerRepo.save(scheduler);
53+
scheduleRepo.delete(schedule);
5154
broadcastUpdate(scheduler);
5255
});
5356

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +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 List<Note> findAll(Specification<Note> specification);
19-
20-
public Page<Note> findAll(Pageable pageable);
18+
public Page<Note> findAllByOrderByLastModifiedDesc(Pageable pageable);
2119

2220
public List<Note> findAllByServiceId(Long id);
2321

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

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

1111
public interface NotificationRepo extends JpaRepository<Notification, Long>, NotificationRepoCustom {
1212

13-
public List<Notification> findByActiveTrue();
13+
public List<Notification> findAllByOrderByIdDesc();
1414

15-
public List<Notification> findByActiveTrueAndLocations(NotificationLocation location);
15+
public List<Notification> findByActiveTrueOrderByIdDesc();
16+
17+
public List<Notification> findByActiveTrueAndLocationsOrderByIdDesc(NotificationLocation location);
1618

1719
public void delete(Notification notification);
1820

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010

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

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

1515
public List<Service> findByIsAuto(Boolean isAuto);
16+
17+
public List<Service> findAllByOrderByIdDesc();
1618

1719
public Long countByStatus(Status status);
1820

src/main/java/edu/tamu/app/model/repo/impl/NotificationRepoImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public void delete(Notification notification) {
5050
public List<Notification> activeNotificationsByLocation(String location) {
5151
List<Notification> notifications = new ArrayList<Notification>();
5252
if (location.equals("ALL")) {
53-
notifications = notificationRepo.findByActiveTrue();
53+
notifications = notificationRepo.findByActiveTrueOrderByIdDesc();
5454
} else {
5555
try {
56-
notifications = notificationRepo.findByActiveTrueAndLocations(NotificationLocation.valueOf(location));
56+
notifications = notificationRepo.findByActiveTrueAndLocationsOrderByIdDesc(NotificationLocation.valueOf(location));
5757
} catch (IllegalArgumentException e) {
5858

5959
}

src/main/java/edu/tamu/app/model/repo/specification/NoteSpecification.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public Predicate toPredicate(Root<E> root, CriteriaQuery<?> query, CriteriaBuild
5050
}
5151

5252
}
53+
54+
query.orderBy(cb.desc(root.get("lastModified")));
5355

5456
Predicate predicate;
5557

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.findByIsPublic(true)) {
46+
for (edu.tamu.app.model.Service service : serviceRepo.findByIsPublicOrderByIdDesc(true)) {
4747
if (service.getStatus().equals(Status.DOWN)) {
4848
publicServicesAreUp = false;
4949
break;

0 commit comments

Comments
 (0)