Skip to content

Commit

Permalink
https://github.com/bonfire-networks/bonfire-app/issues/900
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed Dec 23, 2024
1 parent 670d312 commit a5ee0f9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
4 changes: 2 additions & 2 deletions lib/repo/preload.ex
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ defmodule Bonfire.Common.Repo.Preload do
repo().preload(obj, preloads, opts)
rescue
e in ArgumentError ->
warn(
error(
preloads,
"skipped due to wrong argument: #{inspect(e)}"
)
Expand All @@ -134,7 +134,7 @@ defmodule Bonfire.Common.Repo.Preload do
obj

e ->
warn(preloads, "skipped with rescue: #{inspect(e)} // attempted preloads")
error(preloads, "skipped with rescue: #{inspect(e)} // attempted preloads")
obj
catch
:exit, e ->
Expand Down
50 changes: 29 additions & 21 deletions lib/types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,10 @@ defmodule Bonfire.Common.Types do
Bonfire.Data.Identity.User,
"Bonfire.Data.Identity.User",
"5EVSER1S0STENS1B1YHVMAN01D",
"User",
"Users",
"Person",
"Organization",
"user",
"users",
"person",
"organization",
:user,
:users
],
Expand All @@ -691,8 +691,8 @@ defmodule Bonfire.Common.Types do
when type in [
Bonfire.Data.Social.Post,
"30NF1REP0STTAB1ENVMBER0NEE",
"Posts",
"Post",
"posts",
"post",
:post,
:posts
],
Expand All @@ -701,10 +701,10 @@ defmodule Bonfire.Common.Types do
def object_type(type, opts)
when type in [
Bonfire.Classify.Category,
"Category",
"Categories",
"Group",
"Groups",
"category",
"categories",
"group",
"groups",
:Category,
:Group,
:group,
Expand All @@ -718,8 +718,8 @@ defmodule Bonfire.Common.Types do
# Bonfire.Classify.Category,
# "Category",
# "Categories",
"Topic",
"Topics",
"topic",
"topics",
# :Category,
:Topic
],
Expand All @@ -730,8 +730,8 @@ defmodule Bonfire.Common.Types do
when type in [
Bonfire.Data.Social.Follow,
"70110WTHE1EADER1EADER1EADE",
"Follow",
"Follows",
"follow",
"follows",
:follow
],
do: Bonfire.Data.Social.Follow
Expand All @@ -740,8 +740,8 @@ defmodule Bonfire.Common.Types do
when type in [
Bonfire.Data.Social.Like,
"11KES11KET0BE11KEDY0VKN0WS",
"Like",
"Likes",
"like",
"likes",
:like
],
do: Bonfire.Data.Social.Like
Expand All @@ -750,8 +750,8 @@ defmodule Bonfire.Common.Types do
when type in [
Bonfire.Data.Social.Boost,
"300STANN0VNCERESHARESH0VTS",
"Boost",
"Boosts",
"boost",
"boosts",
:boost
],
do: Bonfire.Data.Social.Boost
Expand All @@ -769,6 +769,8 @@ defmodule Bonfire.Common.Types do
def object_type(type, _opts)
when type in [
ValueFlows.EconomicEvent,
"economicevent",
"economicevents",
"EconomicEvent",
"EconomicEvents",
"2CTVA10BSERVEDF10WS0FVA1VE"
Expand All @@ -782,8 +784,8 @@ defmodule Bonfire.Common.Types do
def object_type(type, _opts)
when type in [
ValueFlows.Planning.Intent,
"Intent",
"Intents",
"intent",
"intents",
"ValueFlows.Planning.Offer",
"ValueFlows.Planning.Need",
"1NTENTC0V1DBEAN0FFER0RNEED"
Expand All @@ -799,7 +801,13 @@ defmodule Bonfire.Common.Types do
schema
else
_ ->
Cache.maybe_apply_cached(&object_type_from_db/2, [id, opts])
query_if_unknown = opts[:query_if_unknown]

if query_if_unknown do
Cache.maybe_apply_cached(&object_type_from_db/2, [id, opts])
else
object_type(String.downcase(id), opts ++ [query_if_unknown: query_if_unknown != false])
end
end
rescue
e in ArgumentError ->
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule Bonfire.Common.MixProject do
# needed for graphql client, eg github for changelog
{:neuron, "~> 5.0", optional: true},
# for extension install + mix tasks that do patching
{:igniter, "~> 0.3", optional: true},
{:igniter, "~> 0.5", optional: true},
# for encryption
{:cloak, "~> 1.1.4", optional: true}
])
Expand Down

0 comments on commit a5ee0f9

Please sign in to comment.