-
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
c4f971c
to
8805e10
Compare
88831b4
to
014df41
Compare
014df41
to
6633d5e
Compare
6633d5e
to
40bc71c
Compare
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.
thanks for the API part @KevSanchez - it must have been a semi-nightmare to adapt everything to the async-ish way of life 😬
I've added only some minor inline notes about details. I haven't been able to use this in action yet - I'm planning to do this tomorrow, if no other emergencies call me in other projects 😬
UPDATE features SET creation_status = 'done' | ||
WHERE creation_status = 'created'; |
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
and created
, 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.
/** | ||
* @debt ? apparently joins in update queries are currently not supported by typeorm yet, so qe require raw SQL here | ||
*/ | ||
await this.geoFeatureTagsRepo.query( | ||
`UPDATE project_feature_tags pft | ||
SET tag = $1 | ||
FROM features f | ||
WHERE f.id = pft.feature_id and pft.project_id = $2 and pft.tag = $3 and f.creation_status = $4`, | ||
[dto.updatedTagName, projectId, dto.tagName, JobStatus.created], | ||
); |
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 am not sure about this - yes, we don't want to allow editing of features that are not fully created
yet... but on the other hand, this should be (I think) an update of a tag at project level, so maybe we could just let it go through?
If feature A (being created) has tag T set at the start of the upload, and while it's still being created a user decides that tag T should be renamed to S, maybe we can make the assumption that T must be renamed to S across all features, so that when feature A gets to created
status, it will have S as tag?
I think this could be open to opinions! I'd suggest to simplify though :/
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.
Hmmm, to add a bit more of confusion, only the feature metadata itself is persisted at the start of the upload, the tag creation is part of the upload transaction, so what would happen if an user uploads a feature with an already existing tag, then in the process it changes that tag at project level? The other tag hasn't been committed and will be persisted as is.
Maybe the tag does get persisted at the start of upload as well and we treat indifferently like you suggest? (I think this doesn't apply to CSV, I recall not having the option to input a tag there)
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.
As we discussed to keep matters simple, and considering that edge case is rather unlikely and not really worth the effort for the complexity it entails, I'm having the PUT/DELETE endpoints for project tags not consider the creationStatus except the GET project tags endpoint.
// Of all three possible creation status, (fail, running, created) we must also include failure and running (if | ||
// indicated in the request) even if they don't intersect with the bounding box (because in those non created | ||
// states there is no geospatial data in the geoDB to intersect with) | ||
const creationStatusSelection = [ | ||
JobStatus.failure, | ||
...(info?.params?.includeInProgress ? [JobStatus.running] : []), | ||
]; |
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.
even though a request may ask for includeInProgress
, wouldn't the intention behind this to retrieve features that are not ready to be used, whether this is because they are "in progress" or because their creation failed?
Or put it another way, should the default (give me all the features) not be "all features that are ready to be used"?
setTimeout(async () => { | ||
await this.createFeaturesForShapefile(projectId, data, featureDatas); | ||
}); | ||
} catch (e) {} |
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.
🤔 why this empty catch
block? IIRC if we throw an error here (could be throw new Error(e)
), this should be caught by the NestJS global exception filter which should handle it as a 500 in this case (again IIRC). We should at least log an error with details, and re-throw the exception (or not catch it at all and let the global exception filter step in)
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.
Ah yes, this is because in order to make this run asynchronously, by wrapping the execution in a setTimeout function, an error thrown inside it completely slips by the global exception filter, as the function gets executed from the global context.
I found this while tweaking the CSV tests that checked for failures, whenever an error was thrown it would terminate the test prematurely.
https://nodejs.org/dist/latest-v7.x/docs/api/errors.html#errors_node_js_style_callbacks
https://stackoverflow.com/questions/41431605/how-to-handle-errors-from-settimeout-in-javascript
projectId, | ||
userId, | ||
}); | ||
} catch (e) {} |
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.
same as for the earlier empty catch
block
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.
Same reason as previous one, as well
api/apps/api/test/projects/project-feature-tags/project-tags.e2e-spec.ts
Show resolved
Hide resolved
@@ -264,6 +268,70 @@ export const getFixtures = async () => { | |||
.send(); | |||
}, | |||
// ASSERT | |||
ThenWaitForApiEvent: (topic: string, kind: API_EVENT_KINDS) => { |
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.
just a tiny naming note: for this and for all the following fixture functions that wait for specific API events to be fired, I think they are used as something inbetween acting and asserting, basically holding off until we can do the core assertions... (you've placed the functions within the assert section here, but often within the act section within tests).
No need to do anything, but my suggestion would be to treat them as assertions throughout, with names such as ThenA<kind>EventIsSubmitted
, but well, yes, it's hair-splitting on naming, so up to you 😄
40bc71c
to
5578410
Compare
5578410
to
197ba50
Compare
Substitute this line for a meaningful title for your changes
Overview
This PR fetches and handles features at project level that has not being processed yet by the API but we need to display its status in the table.
"Running" features (features being processed) cannot be selected, edited, deleted or visible on map.
"Failed" features cannot be edited nor visible on map. They can be selected and deleted though.
Designs
Link to the related design prototypes (if applicable)
Testing instructions
Please explain how to test the PR: ID of a dataset, steps to reach the feature, etc.
Feature relevant tickets
https://vizzuality.atlassian.net/browse/MRXN23-581
Checklist before submitting
develop
.deploying to staging/production, please add brief testing instructions
to the deploy checklist (
docs/deployment-checklist.md
)