This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Helpdesk.Tickets.Ticket.Relationships.TicketsAboveThreshold do | |
use Ash.Resource.ManualRelationship | |
use AshPostgres.ManualRelationship | |
require Ash.Query | |
require Ecto.Query | |
def load(records, _opts, %{query: query, actor: actor, authorize?: authorize?}) do | |
rep_ids = Enum.map(records, & &1.id) | |
{:ok, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mix.Tasks.DumpHackerNews do | |
@moduledoc "Grabs the current first few pages of hackernews and saves them to a json file" | |
use Mix.Task | |
defmodule TopStory do | |
@moduledoc false | |
use Ash.Resource, | |
data_layer: AshJsonApiWrapper.DataLayer | |
json_api_wrapper do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code_change = | |
CodeChange.new() # just one potential idea for what the multi-file tracking would be called | |
|> CodeChange.create_file(path, initial_contents) | |
|> CodeChange.update_file(path, [ | |
Operation.add_defmodule(module_name), | |
Operation.add_use_to_module(module_name, thing_it_uses), | |
MyCustomOperations.do_my_special_thing(...) | |
], instructions_on_failure: "Add x to your module.") | |
# I need this for my use case because individual code changes may depend on the current state of other files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Credo.NoAliasInResources do | |
@moduledoc "A custom lint rule that says there should be no aliases in resource files." | |
use Credo.Check, | |
category: :warning, | |
base_priority: :normal, | |
param_defaults: [], | |
explanations: [ | |
check: """ | |
For consistencies sake, we don't use aliases in resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Types.StringLiteral do | |
@moduledoc "An ash type for a string that can only take a single value. Used in codegen to create literal values." | |
use Ash.Type | |
@constraints [ | |
value: [ | |
type: :string, | |
doc: "The string literal value", | |
required: true | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Types.Union do | |
@constraints [ | |
types: [ | |
type: {:custom, __MODULE__, :union_types, []}, | |
doc: """ | |
The types to be unioned, a map of a string name for the enum value to its configuration. | |
For example: | |
%{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Extensions.Archive.Transformers.SetupArchival do | |
@moduledoc "Sets up the required resource structure for archival" | |
use Ash.Dsl.Transformer | |
@after_transformers [ | |
Ash.Resource.Transformers.SetPrimaryActions | |
] | |
@before_transformers [ | |
Ash.Resource.Transformers.DefaultAccept, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let habits = new Set(); | |
const linksToHabits = {}; | |
let days = []; | |
function compareName(a, b) { | |
if (a.file.name < b.file.name) { | |
return -1; | |
} | |
if (a.file.name > b.file.name) { | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defp changed?(form) do | |
is_changed?(form) || | |
Enum.any?(form.forms, fn {_key, forms} -> | |
forms | |
|> List.wrap() | |
|> Enum.any?(&changed?/1) | |
end) | |
end | |
defp is_changed?(form) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule AshPhoenix.Components.DataTable2 do | |
use Surface.LiveComponent | |
import AshPhoenix.LiveView | |
alias AshPhoenix.Components.FilterBuilder2 | |
data data, :list, default: [] | |
data fields, :list | |
data apply_filter, :boolean, default: true | |
data filter, :any, default: [] |