-
Notifications
You must be signed in to change notification settings - Fork 5
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
[MRXN23-581] inventory panel: features in progress #1649
Merged
+942
−255
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
api/apps/api/src/migrations/api/1708099064649-AddFeatureShapefileApiEvents.ts
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,32 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddFeatureShapefileApiEvents1708099064649 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
INSERT INTO api_event_kinds (id) values | ||
('features.shapefile.import.submitted/v1/alpha'), | ||
('features.shapefile.import.finished/v1/alpha'), | ||
('features.shapefile.import.failed/v1/alpha') | ||
`); | ||
|
||
await queryRunner.query(` | ||
UPDATE features SET creation_status = 'created' | ||
WHERE creation_status = 'done'; | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
DELETE FROM api_event_kinds WHERE id IN ( | ||
'features.shapefile.import.submitted/v1/alpha', | ||
'features.shapefile.import.finished/v1/alpha', | ||
'features.shapefile.import.failed/v1/alpha') | ||
`); | ||
await queryRunner.query(` | ||
UPDATE features SET creation_status = 'done' | ||
WHERE creation_status = 'created'; | ||
`); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
api/apps/api/src/modules/geo-features/adapters/feature-shapefile-upload-api-events.ts
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,37 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { API_EVENT_KINDS } from '@marxan/api-events'; | ||
import { ApiEventsService } from '@marxan-api/modules/api-events'; | ||
import { | ||
FeatureShapefileImportEventsPort, | ||
FeatureShapefileImportState, | ||
} from '@marxan-api/modules/geo-features/ports/feature-shapefile-import-events-port'; | ||
|
||
@Injectable() | ||
export class FeatureShapefileImportApiEvents | ||
extends ApiEventsService | ||
implements FeatureShapefileImportEventsPort | ||
{ | ||
private readonly eventsMap: Record< | ||
FeatureShapefileImportState, | ||
API_EVENT_KINDS | ||
> = { | ||
[FeatureShapefileImportState.FeatureShapefileSubmitted]: | ||
API_EVENT_KINDS.features__shapefile__import__submitted__v1__alpha, | ||
[FeatureShapefileImportState.FeatureShapefileFinished]: | ||
API_EVENT_KINDS.features__shapefile__import__finished__v1__alpha, | ||
[FeatureShapefileImportState.FeatureShapefileFailed]: | ||
API_EVENT_KINDS.features__shapefile__import__failed__v1__alpha, | ||
}; | ||
|
||
async event( | ||
projectId: string, | ||
state: FeatureShapefileImportState, | ||
context?: Record<string, unknown>, | ||
): Promise<void> { | ||
await this.create({ | ||
data: context ?? {}, | ||
topic: projectId, | ||
kind: this.eventsMap[state], | ||
}); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
api/apps/api/src/modules/geo-features/adapters/geo-features-adapters.module.ts
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,16 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ApiEventsModule } from '../../api-events'; | ||
import { FeatureShapefileImportEventsPort } from '@marxan-api/modules/geo-features/ports/feature-shapefile-import-events-port'; | ||
import { FeatureShapefileImportApiEvents } from '@marxan-api/modules/geo-features/adapters/feature-shapefile-upload-api-events'; | ||
|
||
@Module({ | ||
imports: [ApiEventsModule], | ||
providers: [ | ||
{ | ||
provide: FeatureShapefileImportEventsPort, | ||
useClass: FeatureShapefileImportApiEvents, | ||
}, | ||
], | ||
exports: [FeatureShapefileImportEventsPort], | ||
}) | ||
export class GeoFeaturesAdaptersModule {} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think we should avoid this - the up side of this migration is destructive, and we cannot properly undo this (until now we've been using a mix of
done
andcreated
, and we have no way to know which of the two was set before up side of the migration run).I don't think this (being able to restore the original
confirmation_status
is very important, though (mostly, I think we did not make any real use of this flag until now), so I suggest to maybe just put in a small comment explaining that we cannot reliably roll back the relevant part of the up side of the migration.