Skip to content

Commit

Permalink
hide quick stacks from stacks query
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Sep 27, 2022
1 parent 86ae1c1 commit bc0bf7d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/core/lib/core/schema/stack.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Core.Schema.Stack do
schema "stacks" do
field :name, :string
field :description, :string
field :featured, :boolean, default: :false
field :featured, :boolean, default: false
field :display_name, :string
field :bundles, :map, virtual: true
field :expires_at, :utc_datetime_usec
Expand All @@ -19,6 +19,8 @@ defmodule Core.Schema.Stack do
timestamps()
end

def permanent(query \\ __MODULE__), do: from(s in query, where: is_nil(s.expires_at))

def featured(query \\ __MODULE__), do: from(s in query, where: s.featured)

def expired(query \\ __MODULE__) do
Expand Down
1 change: 1 addition & 0 deletions apps/core/test/services/recipes_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ defmodule Core.Services.RecipesTest do
assert is_binary(stack.name)
assert stack.creator_id == user.id
assert stack.expires_at
refute stack.featured

%{collections: [collection]} = Core.Repo.preload(stack, [collections: :bundles])

Expand Down
1 change: 1 addition & 0 deletions apps/graphql/lib/graphql/resolvers/recipe.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ defmodule GraphQl.Resolvers.Recipe do

def list_stacks(args, %{context: %{current_user: user}}) do
Stack.ordered()
|> Stack.permanent()
|> stack_filters(args, user)
|> paginate(args)
end
Expand Down

0 comments on commit bc0bf7d

Please sign in to comment.