sriky27
sriky27
AEAsh Elixir
Created by sriky27 on 6/5/2023 in #support
Possibility to have prepare statement for create, update, delete actions
thanks Zach.
4 replies
AEAsh Elixir
Created by sriky27 on 4/14/2023 in #support
cross_join on a Ash.Query
Thanks Zach I will try it out.
17 replies
AEAsh Elixir
Created by sriky27 on 4/14/2023 in #support
cross_join on a Ash.Query
There are reservations which are made, now trying to find the timeslots which are not allocated
17 replies
AEAsh Elixir
Created by sriky27 on 4/14/2023 in #support
cross_join on a Ash.Query
Basic idea was to generate the time slots which are not reserved
17 replies
AEAsh Elixir
Created by sriky27 on 4/14/2023 in #support
cross_join on a Ash.Query
Hi Zach, Here is the example. I could not figure out how to convert this to ash query or use query in the first place.
prepare(fn query, _context ->
ecto_query = from r in AshResource,
cross_join: t in fragment("SELECT generate_series(?::timestamp, ?::timestamp, '30 min'::interval)", ^start_at, ^end_at),
on: overlaps(tsrange(r.start_date, r.end_at), t) and r.canceled == false and r.resource_id == ^resource_id
end)
prepare(fn query, _context ->
ecto_query = from r in AshResource,
cross_join: t in fragment("SELECT generate_series(?::timestamp, ?::timestamp, '30 min'::interval)", ^start_at, ^end_at),
on: overlaps(tsrange(r.start_date, r.end_at), t) and r.canceled == false and r.resource_id == ^resource_id
end)
17 replies
AEAsh Elixir
Created by sriky27 on 3/13/2023 in #support
Cache layer to Ash rest api
@Zach Daniel super thanks for your quick responses. Falling in love this framework.
7 replies
AEAsh Elixir
Created by sriky27 on 3/13/2023 in #support
Cache layer to Ash rest api
Got it thanks.
7 replies
AEAsh Elixir
Created by sriky27 on 3/13/2023 in #support
Exdocs for Ash rest api
Thank you so much. This helps
7 replies
AEAsh Elixir
Created by sriky27 on 2/21/2023 in #support
query filter with fragment issues
you are super quick in responding to issues
9 replies
AEAsh Elixir
Created by sriky27 on 2/21/2023 in #support
query filter with fragment issues
got it thanks a lot
9 replies
AEAsh Elixir
Created by sriky27 on 2/21/2023 in #support
query filter with fragment issues
{:error,
%Ash.Error.Invalid{
errors: [
%Ash.Error.Query.InvalidArgument{
field: :resource_id,
message: "is invalid",
value: 'aa72fae6-c37b-45ce-8ea3-77de9fbab85d',
changeset: nil,
query: nil,
error_context: [],
vars: [],
path: [],
stacktrace: #Stacktrace<>,
class: :invalid
}
],
stacktraces?: true,
changeset: nil,
query: #Ash.Query<
resource: Reservation.Reserve.ReservationItem,
arguments: %{
duration: 10,
end_date: ~U[2022-01-01 09:59:00Z],
resource_id: 'aa72fae6-c37b-45ce-8ea3-77de9fbab85d',
start_date: ~U[2022-01-01 09:00:00Z]
},
filter: #Ash.Filter<fragment(
{:raw,
"\n SELECT DISTINCT start_at FROM reservation_items e cross join generate_series("},
{:expr, ~U[2022-01-01 09:00:00Z]},
{:raw, "::timestamp , "},
{:expr, ~U[2022-01-01 09:59:00Z]},
{:raw,
"::timestamp, '30 min'::interval) as t\n WHERE tsrange(e.start_at, e.end_at) @> t AND NOT(e.canceled) AND e.resource_id = "},
{:expr, 'aa72fae6-c37b-45ce-8ea3-77de9fbab85d'},
{:raw, ";\n "}
)>,
errors: [
%Ash.Error.Query.InvalidArgument{
field: :resource_id,
message: "is invalid",
value: 'aa72fae6-c37b-45ce-8ea3-77de9fbab85d',
changeset: nil,
query: nil,
error_context: [],
vars: [],
path: [],
stacktrace: #Stacktrace<>,
class: :invalid
}
]
>,
error_context: [nil],
vars: [],
path: [],
stacktrace: #Stacktrace<>,
class: :invalid
}}
{:error,
%Ash.Error.Invalid{
errors: [
%Ash.Error.Query.InvalidArgument{
field: :resource_id,
message: "is invalid",
value: 'aa72fae6-c37b-45ce-8ea3-77de9fbab85d',
changeset: nil,
query: nil,
error_context: [],
vars: [],
path: [],
stacktrace: #Stacktrace<>,
class: :invalid
}
],
stacktraces?: true,
changeset: nil,
query: #Ash.Query<
resource: Reservation.Reserve.ReservationItem,
arguments: %{
duration: 10,
end_date: ~U[2022-01-01 09:59:00Z],
resource_id: 'aa72fae6-c37b-45ce-8ea3-77de9fbab85d',
start_date: ~U[2022-01-01 09:00:00Z]
},
filter: #Ash.Filter<fragment(
{:raw,
"\n SELECT DISTINCT start_at FROM reservation_items e cross join generate_series("},
{:expr, ~U[2022-01-01 09:00:00Z]},
{:raw, "::timestamp , "},
{:expr, ~U[2022-01-01 09:59:00Z]},
{:raw,
"::timestamp, '30 min'::interval) as t\n WHERE tsrange(e.start_at, e.end_at) @> t AND NOT(e.canceled) AND e.resource_id = "},
{:expr, 'aa72fae6-c37b-45ce-8ea3-77de9fbab85d'},
{:raw, ";\n "}
)>,
errors: [
%Ash.Error.Query.InvalidArgument{
field: :resource_id,
message: "is invalid",
value: 'aa72fae6-c37b-45ce-8ea3-77de9fbab85d',
changeset: nil,
query: nil,
error_context: [],
vars: [],
path: [],
stacktrace: #Stacktrace<>,
class: :invalid
}
]
>,
error_context: [nil],
vars: [],
path: [],
stacktrace: #Stacktrace<>,
class: :invalid
}}
9 replies
AEAsh Elixir
Created by sriky27 on 2/21/2023 in #support
query filter with fragment issues
Item.time_slots(~U[2022-01-01 09:00:00Z], ~U[2022-01-01 09:59:00Z], 10, 'aa72fae6-c37b-45ce-8ea3-77de9fbab85d')
9 replies
AEAsh Elixir
Created by sriky27 on 2/19/2023 in #support
custom statement constraint
Thanks a lot.
12 replies
AEAsh Elixir
Created by sriky27 on 2/19/2023 in #support
custom statement constraint
ok
12 replies
AEAsh Elixir
Created by sriky27 on 2/19/2023 in #support
custom statement constraint
ok let me check that. Thanks for the pointer :).
12 replies
AEAsh Elixir
Created by sriky27 on 2/19/2023 in #support
custom statement constraint
Custom error when constraint is triggered
12 replies
AEAsh Elixir
Created by sriky27 on 2/19/2023 in #support
custom statement constraint
yes
12 replies
AEAsh Elixir
Created by ZachDaniel on 2/5/2023 in #support
Custom Statements
Thanks @Zach Daniel for the quick suggestion.
6 replies
AEAsh Elixir
Created by ZachDaniel on 2/5/2023 in #support
Custom Statements
Few fixes I had to do for making it compile custom_statements do statement :overlapping_appointments do up """ ALTER TABLE appointments ADD CONSTRAINT overlapping_appointments EXCLUDE USING GIST ( doctor_id WITH =, tsrange("from", "until", '[)') WITH && ) WHERE (NOT canceled); """ down """ ALTER TABLE appointments DROP CONSTRAINT overlapping_appointments """ end end
6 replies