infrastructure for detecting limited accounts (#320)

This commit is contained in:
Michael Quigley 2023-05-16 12:05:30 -04:00
parent 9591f5150e
commit d0cedaf6e5
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 18 additions and 5 deletions

View File

@ -84,8 +84,20 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
}
envShrsList = append(envShrsList, envShrs)
}
var alj *store.AccountLimitJournal
aljEmpty, err := str.IsAccountLimitJournalEmpty(int(principal.ID), tx)
if err != nil {
logrus.Errorf("error checking account limit journal for '%v': %v", principal.Email, err)
}
if !aljEmpty {
alj, err = str.FindLatestAccountLimitJournal(int(principal.ID), tx)
if err != nil {
logrus.Errorf("error getting latest account limit journal entry for '%v': %v", principal.Email, err)
return metadata.NewOverviewInternalServerError()
}
}
return metadata.NewOverviewOK().WithPayload(&rest_model_zrok.Overview{
AccountLimited: false,
AccountLimited: alj != nil && alj.Action == store.LimitAction,
Environments: envShrsList,
})
}

View File

@ -11,7 +11,7 @@ const Visualizer = (props) => {
useEffect(() => {
console.log("visualizer overview", props.overview);
setNetworkGraph(mergeGraph(networkGraph, props.user, props.overview.environments));
setNetworkGraph(mergeGraph(networkGraph, props.user, props.overview.accountLimited, props.overview.environments));
if(isSelectionGone(networkGraph, props.selection)) {
// if the selection is no longer in the network graph...

View File

@ -15,7 +15,7 @@ const nodesEqual = (a, b) => {
return a.every((e, i) => e.id === b[i].id && e.limited === b[i].limited);
}
export const mergeGraph = (oldGraph, user, newOverview) => {
export const mergeGraph = (oldGraph, user, accountLimited, newOverview) => {
let newGraph = {
nodes: [],
links: []
@ -25,6 +25,7 @@ export const mergeGraph = (oldGraph, user, newOverview) => {
id: user.token,
label: user.email,
type: "account",
limited: !!accountLimited,
val: 50
}
newGraph.nodes.push(accountNode);
@ -36,7 +37,7 @@ export const mergeGraph = (oldGraph, user, newOverview) => {
label: env.environment.description,
type: "environment",
val: 50,
limited: env.limited
limited: !!env.limited || accountNode.limited
};
newGraph.nodes.push(envNode);
newGraph.links.push({
@ -55,7 +56,7 @@ export const mergeGraph = (oldGraph, user, newOverview) => {
envZId: env.environment.zId,
label: shrLabel,
type: "share",
limited: !!shr.limited,
limited: !!shr.limited || envNode.limited,
val: 50
};
newGraph.nodes.push(shrNode);