-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Archivage automatique des signalements de FAR manquant (24h) (#2598)
## Linked issues - Resolve #2584 ----
- Loading branch information
Showing
12 changed files
with
162 additions
and
15 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...otlin/fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicReportingController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package fr.gouv.cnsp.monitorfish.infrastructure.api.public_api | ||
|
||
import fr.gouv.cnsp.monitorfish.domain.use_cases.reporting.ArchiveReporting | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import jakarta.websocket.server.PathParam | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.PutMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/reportings") | ||
@Tag(name = "Public APIs for reporting") | ||
class PublicReportingController( | ||
private val archiveReporting: ArchiveReporting, | ||
) { | ||
|
||
@PutMapping(value = ["/{reportingId}/archive"]) | ||
@Operation(summary = "Archive a reporting") | ||
fun archiveReporting( | ||
@PathParam("Reporting id") | ||
@PathVariable(name = "reportingId") | ||
reportingId: Int, | ||
) { | ||
archiveReporting.execute(reportingId) | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...fr/gouv/cnsp/monitorfish/infrastructure/api/public_api/PublicReportingControllerITests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package fr.gouv.cnsp.monitorfish.infrastructure.api.public_api | ||
|
||
import fr.gouv.cnsp.monitorfish.config.OIDCProperties | ||
import fr.gouv.cnsp.monitorfish.config.SecurityConfig | ||
import fr.gouv.cnsp.monitorfish.config.SentryConfig | ||
import fr.gouv.cnsp.monitorfish.domain.use_cases.reporting.ArchiveReporting | ||
import org.junit.jupiter.api.Test | ||
import org.mockito.Mockito | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.context.annotation.Import | ||
import org.springframework.test.web.servlet.MockMvc | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status | ||
|
||
@Import(SecurityConfig::class, OIDCProperties::class, SentryConfig::class) | ||
@WebMvcTest(value = [PublicReportingController::class]) | ||
class PublicReportingControllerITests { | ||
|
||
@Autowired | ||
private lateinit var api: MockMvc | ||
|
||
@MockBean | ||
private lateinit var archiveReporting: ArchiveReporting | ||
|
||
@Test | ||
fun `Should archive a reporting`() { | ||
// When | ||
api.perform(put("/api/v1/reportings/123/archive")) | ||
// Then | ||
.andExpect(status().isOk) | ||
|
||
Mockito.verify(archiveReporting).execute(123) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
datascience/src/pipeline/queries/monitorfish/non_archived_reportings_of_type.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT id | ||
FROM reportings | ||
WHERE value->>'type' = :reporting_type AND NOT archived |
3 changes: 0 additions & 3 deletions
3
datascience/src/pipeline/queries/monitorfish/pending_alerts_of_config_name.sql
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
datascience/src/pipeline/queries/monitorfish/pending_alerts_of_type.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT id | ||
FROM pending_alerts | ||
WHERE value->>'type' = :alert_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
datascience/tests/test_data/remote_database/V666.20__Reset_test_reportings.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
DELETE FROM reportings; | ||
|
||
INSERT INTO reportings ( | ||
type, vessel_id, internal_reference_number, external_reference_number, ircs, vessel_name, vessel_identifier, creation_date, validation_date, archived, deleted, flag_state, value) VALUES | ||
( 'ALERT', 6, NULL, 'ZZTOPACDC', 'ZZ000000', 'I DO 4H REPORT', 'IRCS', NOW() - ('1 DAY')::interval, NOW(), false, false, 'FR' ,'{"seaFront": "NAMO", "riskFactor": 3.5647, "type": "THREE_MILES_TRAWLING_ALERT", "natinfCode": 7059}'::jsonb); | ||
id, type, vessel_id, internal_reference_number, external_reference_number, ircs, vessel_name, vessel_identifier, creation_date, validation_date, archived, deleted, flag_state, value) VALUES | ||
( 56, 'ALERT', 6, NULL, 'ZZTOPACDC', 'ZZ000000', 'I DO 4H REPORT', 'IRCS', NOW() - ('1 DAY')::interval, NOW(), false, false, 'FR' ,'{"seaFront": "NAMO", "riskFactor": 3.5647, "type": "THREE_MILES_TRAWLING_ALERT", "natinfCode": 7059}'::jsonb); |
2 changes: 2 additions & 0 deletions
2
datascience/tests/test_data/remote_database/V666.8__Reset_test_pending_alerts.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters