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

Add Application migration and instances endpoint #1813

Merged
merged 5 commits into from
Mar 22, 2023

Conversation

knolleary
Copy link
Member

This is a continuation of the work to introduce the Application concept into the runtime.

It targets the feat-1735-application-model branch which introduces the Application model and basic CRUD API.

This PR adds to that branch:

  • A migration that generates an Application object for every existing Project.
  • The /api/v1/applications/:applicationId/instances endpoint that lists the instances within an application
  • Updates the Project views to include the Application info

@knolleary knolleary requested a review from Pezmc March 13, 2023 22:23
@knolleary knolleary marked this pull request as draft March 14, 2023 10:33
@knolleary knolleary marked this pull request as ready for review March 20, 2023 10:16
createdAt: raw.createdAt,
updatedAt: raw.updatedAt,
links: raw.links
if (application) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this responsible for guarding against application being null? That feels like it belongs in whatever view is calling this view.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was self-consistent with the Team view that does the same thing. I'm okay with it as-is.

@@ -33,7 +33,14 @@ module.exports = {

const settingsHostnameRow = proj.ProjectSettings?.find((projectSettingsRow) => projectSettingsRow.key === KEY_HOSTNAME)
result.hostname = settingsHostnameRow?.value || ''

if (proj.Application) {
result.application = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also use app.db.views.Application.application?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app.db.views.Application.application is intended to be the full view of the application.

Here we only want a summary - as we do in the later lines that add a team summary without deferring to a specific view.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like something that should be centralised e.g. app.db.views.Application.application(application, summary: true) rather than spreading throughout the app

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed a change to introduce applicationSummary in line with the teamSummary view we already had. In doing so, I've hit the reason for why they weren't currently used. In this code path, proj.Application has already been converted to a vanilla object - it is no longer a database model object. The summary view was intended for use against the database model object.

I've updated the view to check if its a vanilla object or not and to do the required conversion.

It isn't perhaps the cleanest approach, but it works for now and shouldn't hold up progress on the broader Application work.

forge/db/views/Project.js Outdated Show resolved Hide resolved
forge/db/models/Project.js Outdated Show resolved Hide resolved
Copy link
Contributor

@Pezmc Pezmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks to be in a good place, but see comments above for some polish suggestions!

forge/db/models/Project.js Outdated Show resolved Hide resolved
forge/db/views/Project.js Outdated Show resolved Hide resolved
Co-authored-by: Pez Cuckow <email@pezcuckow.com>
@knolleary
Copy link
Member Author

I have merged the suggested changes. A couple of the other comments regarding views I'm happy to leave as-is because the current code is relatively self-consistent with other views - and I don't want to get into a big refactoring of the views.

@knolleary knolleary requested a review from Pezmc March 21, 2023 17:22
@Pezmc Pezmc merged commit 72e7bb0 into feat-1735-application-model Mar 22, 2023
@Pezmc Pezmc deleted the application-migration branch March 22, 2023 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants