Skip to content

Commit

Permalink
add insight warning status, last used at column
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Sep 27, 2024
1 parent 73b1c94 commit 5817a93
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 7 deletions.
1 change: 1 addition & 0 deletions assets/src/components/cd/clusters/UpgradeInsights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const statusToSeverity = {
[UpgradeInsightStatus.Passing]: 'success',
[UpgradeInsightStatus.Failed]: 'danger',
[UpgradeInsightStatus.Unknown]: 'neutral',
[UpgradeInsightStatus.Warning]: 'warning',
} as const satisfies Record<
UpgradeInsightStatus,
ComponentProps<typeof Chip>['severity']
Expand Down
6 changes: 5 additions & 1 deletion assets/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8203,6 +8203,7 @@ export type UpgradeInsightDetail = {
__typename?: 'UpgradeInsightDetail';
id: Scalars['ID']['output'];
insertedAt?: Maybe<Scalars['DateTime']['output']>;
lastUsedAt?: Maybe<Scalars['DateTime']['output']>;
removedIn?: Maybe<Scalars['String']['output']>;
replacedIn?: Maybe<Scalars['String']['output']>;
/** the replacement for this API */
Expand All @@ -8214,6 +8215,8 @@ export type UpgradeInsightDetail = {
};

export type UpgradeInsightDetailAttributes = {
/** the latest timestamp this insight has been observed */
lastUsedAt?: InputMaybe<Scalars['DateTime']['input']>;
removedIn?: InputMaybe<Scalars['String']['input']>;
replacedIn?: InputMaybe<Scalars['String']['input']>;
/** the replacement for this API */
Expand All @@ -8226,7 +8229,8 @@ export type UpgradeInsightDetailAttributes = {
export enum UpgradeInsightStatus {
Failed = 'FAILED',
Passing = 'PASSING',
Unknown = 'UNKNOWN'
Unknown = 'UNKNOWN',
Warning = 'WARNING'
}

export type UpgradePlan = {
Expand Down
7 changes: 6 additions & 1 deletion go/client/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions lib/console/graphql/deployments/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ defmodule Console.GraphQl.Deployments.Cluster do

field :replaced_in, :string
field :removed_in, :string

field :last_used_at, :datetime, description: "the latest timestamp this insight has been observed"
end

@desc "a CAPI provider for a cluster, cloud is inferred from name if not provided manually"
Expand Down Expand Up @@ -639,8 +641,9 @@ defmodule Console.GraphQl.Deployments.Cluster do
field :used, :string, description: "a possibly deprecated API"
field :replacement, :string, description: "the replacement for this API"

field :replaced_in, :string
field :removed_in, :string
field :replaced_in, :string
field :removed_in, :string
field :last_used_at, :datetime

timestamps()
end
Expand Down
3 changes: 1 addition & 2 deletions lib/console/schema/upgrade_insight.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Console.Schema.UpgradeInsight do
use Piazza.Ecto.Schema
alias Console.Schema.{Cluster, UpgradeInsightDetail}

defenum Status, passing: 0, failed: 1, unknown: 2
defenum Status, passing: 0, failed: 1, unknown: 2, warning: 3

schema "upgrade_insights" do
field :name, :string
Expand All @@ -12,7 +12,6 @@ defmodule Console.Schema.UpgradeInsight do
field :refreshed_at, :utc_datetime_usec
field :transitioned_at, :utc_datetime_usec


has_many :details, UpgradeInsightDetail,
foreign_key: :insight_id,
on_replace: :delete
Expand Down
4 changes: 3 additions & 1 deletion lib/console/schema/upgrade_insight_detail.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ defmodule Console.Schema.UpgradeInsightDetail do
field :replaced_in, :string
field :removed_in, :string

field :last_used_at, :utc_datetime_usec

belongs_to :insight, UpgradeInsight

timestamps()
end

def changeset(model, attrs \\ %{}) do
model
|> cast(attrs, ~w(status used replacement replaced_in removed_in insight_id)a)
|> cast(attrs, ~w(status used replacement replaced_in removed_in insight_id last_used_at)a)
|> foreign_key_constraint(:insight_id)
|> validate_required(~w(status used replacement)a)
end
Expand Down
9 changes: 9 additions & 0 deletions priv/repo/migrations/20240927162949_add_uid_last_used_at.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Console.Repo.Migrations.AddUidLastUsedAt do
use Ecto.Migration

def change do
alter table(:upgrade_insight_details) do
add :last_used_at, :utc_datetime_usec
end
end
end
6 changes: 6 additions & 0 deletions schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3519,6 +3519,7 @@ enum UpgradeInsightStatus {
PASSING
FAILED
UNKNOWN
WARNING
}

enum Conjunction {
Expand Down Expand Up @@ -3783,6 +3784,9 @@ input UpgradeInsightDetailAttributes {
replacedIn: String

removedIn: String

"the latest timestamp this insight has been observed"
lastUsedAt: DateTime
}

"a CAPI provider for a cluster, cloud is inferred from name if not provided manually"
Expand Down Expand Up @@ -4348,6 +4352,8 @@ type UpgradeInsightDetail {

removedIn: String

lastUsedAt: DateTime

insertedAt: DateTime

updatedAt: DateTime
Expand Down

0 comments on commit 5817a93

Please sign in to comment.