-
-
Notifications
You must be signed in to change notification settings - Fork 658
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
feat: applicaton usage endpoint #4548
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
}); | ||
|
||
const reduceRows = (rows: any[]): IClientApplication[] => { |
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.
Since we are joining usage
table, there are duplicate entries, which we are reducing into usage
object.
const existingApp = acc[row.app_name]; | ||
|
||
if (existingApp) { | ||
let project = existingApp.usage.find( |
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.
could be const
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.
Done
project: joi.string().allow('').optional(), | ||
environment: joi.string().allow('').optional(), |
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.
Is joi still in use? I thought OpenAPI was handling validation now.
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.
Yes, we have around 63 usages of this kind of validation. If we are creating anything new, we go with OpenAPI, but older endpoints use it.
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.
But we do have an application-schema.ts. Does this not handle the validation?
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.
This is used for response, but joi is doing for request.
(usage) => usage.project === row.project, | ||
); | ||
|
||
if (project) { | ||
project.environments.push(row.environment); | ||
} else { | ||
existingApp.usage.push({ | ||
project: row.project, | ||
environments: [row.environment], | ||
}); | ||
} | ||
} else { | ||
const mappedRow = mapRow(row); | ||
acc[row.app_name] = { | ||
...mappedRow, | ||
usage: | ||
row.project && row.environment | ||
? [ | ||
{ | ||
project: row.project, | ||
environments: [row.environment], | ||
}, | ||
] | ||
: [], | ||
}; |
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.
Spent a fair bit of time looking at this function to figure out what it does. Could we simplify it?
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.
Refactored a little, but cant do much more.
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.
LGTM
No description provided.