Skip to content
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

fix(SILVA-563): fixing recent openings #455

Merged
merged 95 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from 93 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
09f5a41
chore(deps): code refactor
paulushcgcj Oct 28, 2024
5ceb7e6
chore(deps): removing swagger
paulushcgcj Oct 28, 2024
4d36f7c
chore: changing annoying checkstyle config
paulushcgcj Oct 28, 2024
aa4746a
chore: fixing test
paulushcgcj Oct 28, 2024
3cb574a
chore(test): updating test related config and data
paulushcgcj Oct 28, 2024
acca0f9
ci: updating sonar and jacoco exclusions
paulushcgcj Oct 28, 2024
22f1105
test: adding jwt mock
paulushcgcj Oct 28, 2024
7e9c1c8
chore: updating timestamp util and test
paulushcgcj Oct 28, 2024
3b93d13
chore: simplified code and updated tests
paulushcgcj Oct 28, 2024
f2ffa55
chore: renamed test and added display name
paulushcgcj Oct 28, 2024
ea70089
chore: package and class rename
paulushcgcj Oct 28, 2024
6dba48e
chore: simplifying database connection
paulushcgcj Oct 28, 2024
c4da7a6
chore: simplifying database connection
paulushcgcj Oct 28, 2024
7f1f93d
Merge branch 'main' into feat/SILVA-514
paulushcgcj Oct 28, 2024
3ec7991
feat(SILVA-514): adding backend api for favorites
paulushcgcj Oct 28, 2024
dcea8aa
Merge branch 'main' into feat/SILVA-514
paulushcgcj Oct 29, 2024
037aed9
Merge branch 'main' into feat/SILVA-514
paulushcgcj Oct 29, 2024
8dd24a2
chore: fixing entity by adding the schemas
paulushcgcj Oct 29, 2024
2e18902
Merge branch 'main' into feat/SILVA-514
paulushcgcj Oct 30, 2024
209529f
Merge branch 'main' into feat/SILVA-514
paulushcgcj Oct 30, 2024
8b50df3
Merge branch 'main' into feat/SILVA-514
paulushcgcj Nov 4, 2024
ce66764
test: fixing backend tests
paulushcgcj Nov 4, 2024
3f5bd9d
chore: changing backend imports and logs
paulushcgcj Nov 4, 2024
dd20681
feat: added fav/trends request to backend
paulushcgcj Nov 4, 2024
fe8585e
chore: extracted types from service
paulushcgcj Nov 4, 2024
53fbaaa
test: added test to OpeningService
paulushcgcj Nov 4, 2024
5e7e182
chore: changing type location
paulushcgcj Nov 4, 2024
05c8ddc
test: added test to OpeningHistory
paulushcgcj Nov 4, 2024
6fc8de7
test: updating tests due to code change
paulushcgcj Nov 4, 2024
7b4bd74
chore: changed log message
paulushcgcj Nov 4, 2024
eac2b6d
feat(SILVA-514): updated fav button to include callback
paulushcgcj Nov 4, 2024
bd27a18
chore: function renamed
paulushcgcj Nov 4, 2024
cd69169
feat(SILVA-514): updated OpeningHistory
paulushcgcj Nov 5, 2024
c062fdd
feat(SILVA-514): added the function to add to fav
paulushcgcj Nov 5, 2024
4a1bbae
chore: addressing sonar issues
paulushcgcj Nov 5, 2024
03deefa
fix: fixing opening id value
paulushcgcj Nov 5, 2024
22ed6cb
fix: fixing an issue with request timeout
paulushcgcj Nov 5, 2024
b984e1a
chore: removing duplicated import
paulushcgcj Nov 5, 2024
ab22c75
chore: fixing sonar issues
paulushcgcj Nov 6, 2024
b9da88d
test: adding more tests to Opening screen
paulushcgcj Nov 6, 2024
1327314
Merge branch 'main' into feat/SILVA-514
paulushcgcj Nov 6, 2024
b85a826
test: adding OpeningMetricsTab test
paulushcgcj Nov 6, 2024
61afaa3
test: fixing tests
paulushcgcj Nov 6, 2024
ee15006
chore: removing only
paulushcgcj Nov 6, 2024
b154780
chore(SILVA-403): making toast notification more useful
paulushcgcj Nov 6, 2024
74be87f
Merge branch 'main' into fix/SILVA-403
paulushcgcj Nov 6, 2024
dedb36f
Merge branch 'main' into fix/SILVA-403
paulushcgcj Nov 6, 2024
34ef5f4
chore: code fix
paulushcgcj Nov 6, 2024
7f93a44
Merge branch 'main' into fix/SILVA-403
paulushcgcj Nov 7, 2024
895f039
fix: fixed missing load when removing favorites
paulushcgcj Nov 7, 2024
069b3b0
test: fixing OpeningHistoryTest
paulushcgcj Nov 7, 2024
5202413
chore: fixing sonar issues
paulushcgcj Nov 7, 2024
ea31752
chore: fixing sonar issues
paulushcgcj Nov 7, 2024
9947704
chore: fixing sonar issues
paulushcgcj Nov 7, 2024
bcfc6de
chore: removing reducer
paulushcgcj Nov 7, 2024
d433346
chore: removing redux dependencies
paulushcgcj Nov 7, 2024
62aefea
chore: removing redux spillouts
paulushcgcj Nov 7, 2024
4ad00e0
chore: removing unused file
paulushcgcj Nov 7, 2024
33db56f
chore: fixing sonar isues
paulushcgcj Nov 7, 2024
784d370
chore: removing actions
paulushcgcj Nov 7, 2024
5817fec
chore: removing help screen
paulushcgcj Nov 7, 2024
0a72bfd
chore: route cleanup
paulushcgcj Nov 7, 2024
85a7a5b
chore: sonar cleanup
paulushcgcj Nov 7, 2024
af59cff
chore: removing test for deleted files
paulushcgcj Nov 7, 2024
9a7fda0
chore: fixing sonar issues
paulushcgcj Nov 7, 2024
6e1bce6
chore: disabling unused tabs
paulushcgcj Nov 7, 2024
58a1a6a
chore: fixing sonar issues
paulushcgcj Nov 7, 2024
b7eb156
chore(ci): configuring sonar exclusion
paulushcgcj Nov 7, 2024
6f19481
chore: removing useles prop param
paulushcgcj Nov 7, 2024
9e846ed
chore: sonar fixes
paulushcgcj Nov 7, 2024
4815d57
chore: fixing sonar and build issues
paulushcgcj Nov 7, 2024
65f545d
chore: initial OpeningTabs test
paulushcgcj Nov 7, 2024
635db81
test: added ThemeToggle test
paulushcgcj Nov 7, 2024
e563ad5
chore: removing unused component
paulushcgcj Nov 7, 2024
7462014
chore: sonar issues fixed
paulushcgcj Nov 7, 2024
8b23205
chore: removing dummy data
paulushcgcj Nov 7, 2024
dd412ab
fix(SILVA-551): removing free growing graph
paulushcgcj Nov 7, 2024
cf02c29
fix(SILVA-551): adjusting favorite dashboard visuals
paulushcgcj Nov 7, 2024
f668b01
Merge branch 'main' into fix/SILVA-551
paulushcgcj Nov 7, 2024
ce74fcd
chore(SILVA-551): fixed backend for favourites
paulushcgcj Nov 7, 2024
94a5989
fix(SILVA-551): fixed frontend favourites
paulushcgcj Nov 7, 2024
afed337
chore: fixing imports
paulushcgcj Nov 7, 2024
7a5332c
Merge branch 'main' into fix/SILVA-551
paulushcgcj Nov 7, 2024
0878473
Merge branch 'main' into fix/SILVA-551
paulushcgcj Nov 8, 2024
34d66c3
test: fixing a test
paulushcgcj Nov 8, 2024
fff7939
test: fixing test
paulushcgcj Nov 8, 2024
8ebbde7
test: fixing tests
paulushcgcj Nov 8, 2024
6227e23
chore: removed the maximize and download options
paulushcgcj Nov 8, 2024
da6e9dd
fix(SILVA-514): fixing notification for fav/unfav
paulushcgcj Nov 8, 2024
570cfe0
fix(SILVA-516): fixing recent actions on backend
paulushcgcj Nov 8, 2024
15f87d0
Merge branch 'main' into fix/SILVA-516
paulushcgcj Nov 8, 2024
42fa934
fix(SILVA-516): fixing my recent actions
paulushcgcj Nov 8, 2024
8381a76
fix(SILVA-563): Fix recent openings
paulushcgcj Nov 8, 2024
5743332
fix(SILVA-563): fixing disabled search style
paulushcgcj Nov 8, 2024
c554ac1
Merge branch 'main' into fix/SILVA-563
paulushcgcj Nov 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,24 @@ public class SilvaConfiguration {
private ExternalApiAddress forestClientApi;
@NestedConfigurationProperty
private ExternalApiAddress openMaps;
@NestedConfigurationProperty
private SilvaDataLimits limits;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ExternalApiAddress {

private String address;
private String key;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class SilvaDataLimits {
private Integer maxActionsResults;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ca.bc.gov.restapi.results.oracle.endpoint;

import ca.bc.gov.restapi.results.oracle.service.UserActionsService;
import ca.bc.gov.restapi.results.postgres.dto.MyRecentActionsRequestsDto;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/users")
@RequiredArgsConstructor
@Slf4j
public class UserActionsEndpoint {

private final UserActionsService userActionsService;

@GetMapping("/recent-actions")
public ResponseEntity<List<MyRecentActionsRequestsDto>> getUserRecentOpeningsActions() {
List<MyRecentActionsRequestsDto> actionsDto =
userActionsService.getResultsAuditActivity();

log.info("Returning {} recent actions", actionsDto.size());

if (actionsDto.isEmpty()) {
return ResponseEntity.noContent().build();
}

return ResponseEntity.ok(actionsDto);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ca.bc.gov.restapi.results.oracle.entity;

import java.time.LocalDateTime;

public interface ResultsAuditEventProjection {
Long getResultsAuditEventId();
Long getOpeningId();
String getActionCode();
String getActionCodeDescription();
String getCategoryCode();
String getCategoryCodeDescription();
LocalDateTime getEntryTimestamp();
String getEntryUserid();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package ca.bc.gov.restapi.results.oracle.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum AuditActionCodeEnum {
UPD("UPD", "Update"),
COR("COR", "Correction"),
O("O", "Original"),
SEC197("197", "Section 197"),
AMG("AMG", "Amalgamate"),
ES("ES", "E-submission"),
MIL("MIL", "Milestone"),
MIN("MIN", "Amended (Minor)"),
SPA("SPA", "Site Plan Amendment"),
VAR("VAR", "Variation"),
AMD("AMD", "Amended"),
APP("APP", "Approved"),
DEL("DEL", "Deleted"),
REJ("REJ", "Rejected"),
RET("RET", "Retired"),
RMD("RMD", "Removed"),
SUB("SUB", "Submitted");

private final String code;
private final String description;

public static AuditActionCodeEnum of(String code) {
for (AuditActionCodeEnum value : AuditActionCodeEnum.values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ca.bc.gov.restapi.results.oracle.repository;

import ca.bc.gov.restapi.results.oracle.entity.OpeningEntity;
import ca.bc.gov.restapi.results.oracle.entity.ResultsAuditEventProjection;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface ResultsAuditActivityRepository extends JpaRepository<OpeningEntity, Long> {

@Query(
value = """
SELECT
rae.results_audit_event_id,
rae.opening_id,
rae.results_audit_action_code as action_code,
raac.description as action_code_description,
o.open_category_code as category_code,
occ.description as category_code_description,
rae.entry_timestamp,
rae.entry_userid
FROM THE.RESULTS_AUDIT_EVENT rae
LEFT JOIN THE.RESULTS_AUDIT_ACTION_CODE raac ON raac.RESULTS_AUDIT_ACTION_CODE = rae.RESULTS_AUDIT_ACTION_CODE
LEFT JOIN THE.OPENING o ON o.OPENING_ID = rae.OPENING_ID
LEFT JOIN THE.OPEN_CATEGORY_CODE occ ON occ.OPEN_CATEGORY_CODE = o.OPEN_CATEGORY_CODE
WHERE rae.ENTRY_USERID = ?1
ORDER BY rae.ENTRY_TIMESTAMP DESC
FETCH FIRST ?2 ROWS ONLY""",
nativeQuery = true)
List<ResultsAuditEventProjection> findUserRecentAuditEvents(String userId, Integer limit);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package ca.bc.gov.restapi.results.oracle.service;

import ca.bc.gov.restapi.results.common.configuration.SilvaConfiguration;
import ca.bc.gov.restapi.results.common.security.LoggedUserService;
import ca.bc.gov.restapi.results.oracle.repository.ResultsAuditActivityRepository;
import ca.bc.gov.restapi.results.postgres.dto.MyRecentActionsRequestsDto;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.ocpsoft.prettytime.PrettyTime;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class UserActionsService {

private final ResultsAuditActivityRepository auditActivityRepository;
private final LoggedUserService loggedUserService;
private final SilvaConfiguration silvaConfiguration;
private final PrettyTime prettyTime = new PrettyTime();

public List<MyRecentActionsRequestsDto> getResultsAuditActivity() {
String userId = loggedUserService.getLoggedUserId();

log.info("Getting recent audit events for user {}", userId);

return
auditActivityRepository
.findUserRecentAuditEvents(userId, silvaConfiguration.getLimits().getMaxActionsResults())
.stream()
.map(entity ->
new MyRecentActionsRequestsDto(
entity.getActionCodeDescription(),
entity.getOpeningId(),
entity.getCategoryCode(),
entity.getCategoryCodeDescription(),
prettyTime.format(entity.getEntryTimestamp()),
entity.getEntryTimestamp()
)
)
.toList();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ca.bc.gov.restapi.results.common.util.TimestampUtil;
import ca.bc.gov.restapi.results.postgres.dto.DashboardFiltersDto;
import ca.bc.gov.restapi.results.postgres.dto.FreeGrowingMilestonesDto;
import ca.bc.gov.restapi.results.postgres.dto.MyRecentActionsRequestsDto;
import ca.bc.gov.restapi.results.postgres.dto.OpeningsPerYearDto;
import ca.bc.gov.restapi.results.postgres.service.DashboardMetricsService;
import java.util.List;
Expand Down Expand Up @@ -98,20 +97,4 @@ public ResponseEntity<List<FreeGrowingMilestonesDto>> getFreeGrowingMilestonesDa
return ResponseEntity.ok(milestonesDto);
}

/**
* Gets the last 5 most recent updated openings for the request user.
*
* @return A list of values to populate the chart or 204 no content if no data.
*/
@GetMapping("/my-recent-actions/requests")
public ResponseEntity<List<MyRecentActionsRequestsDto>> getUserRecentOpeningsActions() {
List<MyRecentActionsRequestsDto> actionsDto =
dashboardMetricsService.getUserRecentOpeningsActions();

if (actionsDto.isEmpty()) {
return ResponseEntity.noContent().build();
}

return ResponseEntity.ok(actionsDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ca.bc.gov.restapi.results.postgres.entity.OpeningsActivityEntity;
import ca.bc.gov.restapi.results.postgres.entity.OpeningsActivityEntityId;
import java.util.List;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

/**
Expand All @@ -12,7 +12,5 @@
public interface OpeningsActivityRepository
extends JpaRepository<OpeningsActivityEntity, OpeningsActivityEntityId> {

List<OpeningsActivityEntity> findAllByOpeningIdIn(List<Long> openingIds);

List<OpeningsActivityEntity> findAllByEntryUserid(String userId, Sort sort);
List<OpeningsActivityEntity> findAllByEntryUserid(String userId, Pageable page);
}
Loading
Loading