diff --git a/apps/core/lib/core/schema/rollout.ex b/apps/core/lib/core/schema/rollout.ex index e099bd7e6..d9b832ef1 100644 --- a/apps/core/lib/core/schema/rollout.ex +++ b/apps/core/lib/core/schema/rollout.ex @@ -3,6 +3,8 @@ defmodule Core.Schema.Rollout do alias Piazza.Ecto.UUID alias Core.Schema.{Repository} + @expiry -14 + defenum Status, queued: 0, running: 1, finished: 2 schema "rollouts" do @@ -17,6 +19,11 @@ defmodule Core.Schema.Rollout do timestamps() end + def expired(query \\ __MODULE__) do + expiry = Timex.now() |> Timex.shift(days: @expiry) + from(r in query, where: r.inserted_at < ^expiry) + end + def for_repository(query \\ __MODULE__, id) do from(r in query, where: r.repository_id == ^id) end diff --git a/apps/core/lib/core/services/rollouts/rollable/versions.ex b/apps/core/lib/core/services/rollouts/rollable/versions.ex index 36cb973a2..9214f7f78 100644 --- a/apps/core/lib/core/services/rollouts/rollable/versions.ex +++ b/apps/core/lib/core/services/rollouts/rollable/versions.ex @@ -31,7 +31,7 @@ defimpl Core.Rollouts.Rollable, for: [Core.PubSub.VersionCreated, Core.PubSub.Ve def process(%{item: version}, %{installation: %{user: user}} = inst) do case Dependencies.valid?(version.dependencies, user) do true -> directly_install(version, inst) - false -> Upgrades.create_deferred_update(version.id, inst, user) + _ -> Upgrades.create_deferred_update(version.id, inst, user) end end diff --git a/www/src/components/repos/Chart.js b/www/src/components/repos/Chart.js index 2e013d079..d1b8a35a7 100644 --- a/www/src/components/repos/Chart.js +++ b/www/src/components/repos/Chart.js @@ -13,6 +13,8 @@ import moment from 'moment' import { A, Flex } from 'honorable' +import { updateCache } from 'utils/graphql' + import { ResponsiveLayoutContentContainer, ResponsiveLayoutSidecarContainer, @@ -72,26 +74,19 @@ function ChartInfo({ version: { helm, insertedAt } }) { ) } -function ChartInstaller({ chart }) { +function ChartInstaller({ chart, version }) { const [mutation, { error }] = useMutation(chart.installation ? UPDATE_CHART_INST : INSTALL_CHART, { variables: { id: chart.installation ? chart.installation.id : chart.repository.installation.id, - attributes: { chartId: chart.id, versionId: chart.installation?.version?.id }, + attributes: { chartId: chart.id, versionId: version.id }, }, update: (cache, { data }) => { const ci = data.installChart || data.updateChartInstallation - const prev = cache.readQuery({ query: CHART_Q, variables: { chartId: chart.id } }) - cache.writeQuery({ + updateCache(cache, { query: CHART_Q, variables: { chartId: chart.id }, - data: { - ...prev, - chart: { - ...prev.chart, - installation: ci, - }, - }, + update: prev => ({ ...prev, chart: { ...prev.chart, installation: ci } }), }) }, }) @@ -112,7 +107,13 @@ export function ChartActions({ chart, currentVersion, ...props }) { return null } - return + return ( + + + ) } function ImageDependencies({ version: { imageDependencies } }) {