Refactoring of Events context

This commit is contained in:
miffigriffi 2019-09-16 02:07:44 +02:00
parent 6372599493
commit ac77a7d28a
18 changed files with 910 additions and 1158 deletions

View File

@ -65,7 +65,10 @@ defmodule Mobilizon do
{Cachex, :start_link, {Cachex, :start_link,
[ [
name, name,
Keyword.merge(cachex_options(limit, default, interval), fallback_options(fallback)) Keyword.merge(
cachex_options(limit, default, interval),
fallback_options(fallback)
)
]} ]}
} }
end end

View File

@ -45,6 +45,7 @@ defmodule Mobilizon.Actors do
:creator :creator
]) ])
@public_visibility [:public, :unlisted]
@administrator_roles [:creator, :administrator] @administrator_roles [:creator, :administrator]
@doc false @doc false
@ -836,7 +837,7 @@ defmodule Mobilizon.Actors do
from( from(
a in Actor, a in Actor,
where: a.type == ^:Group, where: a.type == ^:Group,
where: a.visibility in ^[:public, :unlisted] where: a.visibility in ^@public_visibility
) )
end end

View File

@ -3,11 +3,19 @@ defmodule Mobilizon.Events.Activity do
Represents an activity. Represents an activity.
""" """
@type t :: %__MODULE__{
data: String.t(),
local: boolean,
actor: Actor.t(),
recipients: [String.t()]
# notifications: [???]
}
defstruct [ defstruct [
:data, :data,
:local, :local,
:actor, :actor,
:recipients, :recipients
:notifications # :notifications
] ]
end end

File diff suppressed because it is too large Load Diff

View File

@ -73,7 +73,7 @@ defmodule MobilizonWeb.API.Reports do
defp get_report_comments(%Actor{id: actor_id}, comment_ids) do defp get_report_comments(%Actor{id: actor_id}, comment_ids) do
{:get_report_comments, {:get_report_comments,
Events.get_all_comments_by_actor_and_ids(actor_id, comment_ids) |> Enum.map(& &1.url)} Events.list_comments_by_actor_and_ids(actor_id, comment_ids) |> Enum.map(& &1.url)}
end end
defp get_report_comments(_, _), do: {:get_report_comments, nil} defp get_report_comments(_, _), do: {:get_report_comments, nil}

View File

@ -68,7 +68,7 @@ defmodule MobilizonWeb.API.Search do
end end
true -> true ->
{:ok, Events.find_and_count_events_by_name(search, page, limit)} {:ok, Events.build_events_by_name(search, page, limit)}
end end
end end

View File

@ -17,12 +17,12 @@ defmodule MobilizonWeb.PageController do
end end
def event(conn, %{"uuid" => uuid}) do def event(conn, %{"uuid" => uuid}) do
{status, event} = Events.get_cached_event_full_by_uuid(uuid) {status, event} = Events.get_cached_public_event_by_uuid_with_preload(uuid)
render_or_error(conn, &ok_status_and_is_visible?/2, status, :event, event) render_or_error(conn, &ok_status_and_is_visible?/2, status, :event, event)
end end
def comment(conn, %{"uuid" => uuid}) do def comment(conn, %{"uuid" => uuid}) do
{status, comment} = Events.get_cached_comment_full_by_uuid(uuid) {status, comment} = Events.get_cached_comment_by_uuid_with_preload(uuid)
render_or_error(conn, &ok_status_and_is_visible?/2, status, :comment, comment) render_or_error(conn, &ok_status_and_is_visible?/2, status, :comment, comment)
end end

View File

@ -25,7 +25,7 @@ defmodule MobilizonWeb.Resolvers.Event do
end end
def find_event(_parent, %{uuid: uuid}, _resolution) do def find_event(_parent, %{uuid: uuid}, _resolution) do
case Mobilizon.Events.get_event_full_by_uuid(uuid) do case Mobilizon.Events.get_public_event_by_uuid_with_preload(uuid) do
nil -> nil ->
{:error, "Event with UUID #{uuid} not found"} {:error, "Event with UUID #{uuid} not found"}
@ -58,14 +58,14 @@ defmodule MobilizonWeb.Resolvers.Event do
) do ) do
# We get the organizer's next public event # We get the organizer's next public event
events = events =
[Events.get_actor_upcoming_public_event(organizer_actor, uuid)] [Events.get_upcoming_public_event_for_actor(organizer_actor, uuid)]
|> Enum.filter(&is_map/1) |> Enum.filter(&is_map/1)
# We find similar events with the same tags # We find similar events with the same tags
# uniq_by : It's possible event_from_same_actor is inside events_from_tags # uniq_by : It's possible event_from_same_actor is inside events_from_tags
events = events =
events events
|> Enum.concat(Events.find_similar_events_by_common_tags(tags, @number_of_related_events)) |> Enum.concat(Events.list_events_by_tags(tags, @number_of_related_events))
|> uniq_events() |> uniq_events()
# TODO: We should use tag_relations to find more appropriate events # TODO: We should use tag_relations to find more appropriate events
@ -104,7 +104,7 @@ defmodule MobilizonWeb.Resolvers.Event do
) do ) do
with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, actor_id), with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, actor_id),
{:has_event, {:ok, %Event{} = event}} <- {:has_event, {:ok, %Event{} = event}} <-
{:has_event, Mobilizon.Events.get_event_full(event_id)}, {:has_event, Mobilizon.Events.get_event_with_preload(event_id)},
{:error, :participant_not_found} <- Mobilizon.Events.get_participant(event_id, actor_id), {:error, :participant_not_found} <- Mobilizon.Events.get_participant(event_id, actor_id),
{:ok, _activity, participant} <- MobilizonWeb.API.Participations.join(event, actor), {:ok, _activity, participant} <- MobilizonWeb.API.Participations.join(event, actor),
participant <- participant <-
@ -141,7 +141,7 @@ defmodule MobilizonWeb.Resolvers.Event do
) do ) do
with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, actor_id), with {:is_owned, %Actor{} = actor} <- User.owns_actor(user, actor_id),
{:has_event, {:ok, %Event{} = event}} <- {:has_event, {:ok, %Event{} = event}} <-
{:has_event, Mobilizon.Events.get_event_full(event_id)}, {:has_event, Mobilizon.Events.get_event_with_preload(event_id)},
{:ok, _activity, _participant} <- MobilizonWeb.API.Participations.leave(event, actor) do {:ok, _activity, _participant} <- MobilizonWeb.API.Participations.leave(event, actor) do
{:ok, %{event: %{id: event_id}, actor: %{id: actor_id}}} {:ok, %{event: %{id: event_id}, actor: %{id: actor_id}}}
else else
@ -200,7 +200,7 @@ defmodule MobilizonWeb.Resolvers.Event do
) do ) do
# See https://github.com/absinthe-graphql/absinthe/issues/490 # See https://github.com/absinthe-graphql/absinthe/issues/490
with args <- Map.put(args, :options, args[:options] || %{}), with args <- Map.put(args, :options, args[:options] || %{}),
{:ok, %Event{} = event} <- Mobilizon.Events.get_event_full(event_id), {:ok, %Event{} = event} <- Mobilizon.Events.get_event_with_preload(event_id),
{:is_owned, %Actor{} = organizer_actor} <- {:is_owned, %Actor{} = organizer_actor} <-
User.owns_actor(user, event.organizer_actor_id), User.owns_actor(user, event.organizer_actor_id),
{:ok, args} <- save_attached_picture(args), {:ok, args} <- save_attached_picture(args),

View File

@ -33,7 +33,7 @@ defmodule MobilizonWeb.Resolvers.Tag do
# """ # """
# def get_related_tags(_parent, %{tag_id: tag_id}, _resolution) do # def get_related_tags(_parent, %{tag_id: tag_id}, _resolution) do
# with %Tag{} = tag <- Mobilizon.Events.get_tag!(tag_id), # with %Tag{} = tag <- Mobilizon.Events.get_tag!(tag_id),
# tags <- Mobilizon.Events.tag_neighbors(tag) do # tags <- Mobilizon.Events.list_tag_neighbors(tag) do
# {:ok, tags} # {:ok, tags}
# end # end
# end # end
@ -42,7 +42,7 @@ defmodule MobilizonWeb.Resolvers.Tag do
Retrieve the list of related tags for a parent tag Retrieve the list of related tags for a parent tag
""" """
def get_related_tags(%Tag{} = tag, _args, _resolution) do def get_related_tags(%Tag{} = tag, _args, _resolution) do
with tags <- Mobilizon.Events.tag_neighbors(tag) do with tags <- Mobilizon.Events.list_tag_neighbors(tag) do
{:ok, tags} {:ok, tags}
end end
end end

View File

@ -84,10 +84,10 @@ defmodule Mobilizon.Service.ActivityPub do
{:ok, _activity, %{url: object_url} = _object} <- Transmogrifier.handle_incoming(params) do {:ok, _activity, %{url: object_url} = _object} <- Transmogrifier.handle_incoming(params) do
case data["type"] do case data["type"] do
"Event" -> "Event" ->
{:ok, Events.get_event_full_by_url!(object_url)} {:ok, Events.get_public_event_by_url_with_preload!(object_url)}
"Note" -> "Note" ->
{:ok, Events.get_comment_full_from_url!(object_url)} {:ok, Events.get_comment_from_url_with_preload!(object_url)}
"Actor" -> "Actor" ->
{:ok, Actors.get_actor_by_url!(object_url, true)} {:ok, Actors.get_actor_by_url!(object_url, true)}
@ -97,10 +97,10 @@ defmodule Mobilizon.Service.ActivityPub do
end end
else else
{:existing_event, %Event{url: event_url}} -> {:existing_event, %Event{url: event_url}} ->
{:ok, Events.get_event_full_by_url!(event_url)} {:ok, Events.get_public_event_by_url_with_preload!(event_url)}
{:existing_comment, %Comment{url: comment_url}} -> {:existing_comment, %Comment{url: comment_url}} ->
{:ok, Events.get_comment_full_from_url!(comment_url)} {:ok, Events.get_comment_from_url_with_preload!(comment_url)}
{:existing_actor, {:ok, %Actor{url: actor_url}}} -> {:existing_actor, {:ok, %Actor{url: actor_url}}} ->
{:ok, Actors.get_actor_by_url!(actor_url, true)} {:ok, Actors.get_actor_by_url!(actor_url, true)}
@ -682,8 +682,8 @@ defmodule Mobilizon.Service.ActivityPub do
""" """
@spec fetch_public_activities_for_actor(Actor.t(), integer(), integer()) :: map() @spec fetch_public_activities_for_actor(Actor.t(), integer(), integer()) :: map()
def fetch_public_activities_for_actor(%Actor{} = actor, page \\ 1, limit \\ 10) do def fetch_public_activities_for_actor(%Actor{} = actor, page \\ 1, limit \\ 10) do
{:ok, events, total_events} = Events.get_public_events_for_actor(actor, page, limit) {:ok, events, total_events} = Events.list_public_events_for_actor(actor, page, limit)
{:ok, comments, total_comments} = Events.get_public_comments_for_actor(actor, page, limit) {:ok, comments, total_comments} = Events.list_public_comments_for_actor(actor, page, limit)
event_activities = Enum.map(events, &event_to_activity/1) event_activities = Enum.map(events, &event_to_activity/1)

View File

@ -45,7 +45,7 @@ defmodule Mobilizon.Service.Export.Feed do
defp fetch_actor_event_feed(name) do defp fetch_actor_event_feed(name) do
with %Actor{} = actor <- Actors.get_local_actor_by_name(name), with %Actor{} = actor <- Actors.get_local_actor_by_name(name),
{:visibility, true} <- {:visibility, Actor.is_public_visibility(actor)}, {:visibility, true} <- {:visibility, Actor.is_public_visibility(actor)},
{:ok, events, _count} <- Events.get_public_events_for_actor(actor) do {:ok, events, _count} <- Events.list_public_events_for_actor(actor) do
{:ok, build_actor_feed(actor, events)} {:ok, build_actor_feed(actor, events)}
else else
err -> err ->

View File

@ -45,7 +45,7 @@ defmodule Mobilizon.Service.Export.ICalendar do
@spec export_public_actor(Actor.t()) :: String.t() @spec export_public_actor(Actor.t()) :: String.t()
def export_public_actor(%Actor{} = actor) do def export_public_actor(%Actor{} = actor) do
with true <- Actor.is_public_visibility(actor), with true <- Actor.is_public_visibility(actor),
{:ok, events, _} <- Events.get_public_events_for_actor(actor) do {:ok, events, _} <- Events.list_public_events_for_actor(actor) do
{:ok, %ICalendar{events: events |> Enum.map(&do_export_event/1)} |> ICalendar.to_ics()} {:ok, %ICalendar{events: events |> Enum.map(&do_export_event/1)} |> ICalendar.to_ics()}
end end
end end
@ -74,7 +74,7 @@ defmodule Mobilizon.Service.Export.ICalendar do
Create cache for an actor Create cache for an actor
""" """
def create_cache("event_" <> uuid) do def create_cache("event_" <> uuid) do
with %Event{} = event <- Events.get_event_full_by_uuid(uuid), with %Event{} = event <- Events.get_public_event_by_uuid_with_preload(uuid),
{:ok, res} <- export_public_event(event) do {:ok, res} <- export_public_event(event) do
{:commit, res} {:commit, res}
else else

View File

@ -4,6 +4,7 @@ defmodule Mobilizon.EventsTest do
import Mobilizon.Factory import Mobilizon.Factory
alias Mobilizon.Events alias Mobilizon.Events
alias Mobilizon.Storage.Page
@event_valid_attrs %{ @event_valid_attrs %{
begins_on: "2010-04-17 14:00:00Z", begins_on: "2010-04-17 14:00:00Z",
@ -47,29 +48,29 @@ defmodule Mobilizon.EventsTest do
refute Ecto.assoc_loaded?(Events.get_event!(event.id).organizer_actor) refute Ecto.assoc_loaded?(Events.get_event!(event.id).organizer_actor)
end end
test "get_event_full!/1 returns the event with given id", %{event: event} do test "get_event_with_preload!/1 returns the event with given id", %{event: event} do
assert Events.get_event_full!(event.id).organizer_actor.preferred_username == assert Events.get_event_with_preload!(event.id).organizer_actor.preferred_username ==
event.organizer_actor.preferred_username event.organizer_actor.preferred_username
assert Events.get_event_full!(event.id).participants == [] assert Events.get_event_with_preload!(event.id).participants == []
end end
test "find_and_count_events_by_name/1 returns events for a given name", %{ test "build_events_by_name/1 returns events for a given name", %{
event: %Event{title: title} = event event: %Event{title: title} = event
} do } do
assert title == hd(Events.find_and_count_events_by_name(event.title).elements).title assert title == hd(Events.build_events_by_name(event.title).elements).title
%Event{} = event2 = insert(:event, title: "Special event") %Event{} = event2 = insert(:event, title: "Special event")
assert event2.title == assert event2.title ==
Events.find_and_count_events_by_name("Special").elements |> hd() |> Map.get(:title) Events.build_events_by_name("Special").elements |> hd() |> Map.get(:title)
assert event2.title == assert event2.title ==
Events.find_and_count_events_by_name(" Special ").elements Events.build_events_by_name(" Special ").elements
|> hd() |> hd()
|> Map.get(:title) |> Map.get(:title)
assert %{elements: [], total: 0} == Events.find_and_count_events_by_name("") assert %Page{elements: [], total: 0} == Events.build_events_by_name("")
end end
test "find_close_events/3 returns events in the area" do test "find_close_events/3 returns events in the area" do
@ -127,19 +128,15 @@ defmodule Mobilizon.EventsTest do
assert_raise Ecto.NoResultsError, fn -> Events.get_event!(event.id) end assert_raise Ecto.NoResultsError, fn -> Events.get_event!(event.id) end
end end
test "change_event/1 returns a event changeset", %{event: event} do test "list_public_events_for_actor/1", %{actor: actor, event: event} do
assert %Ecto.Changeset{} = Events.change_event(event) assert {:ok, [event_found], 1} = Events.list_public_events_for_actor(actor)
end
test "get_public_events_for_actor/1", %{actor: actor, event: event} do
assert {:ok, [event_found], 1} = Events.get_public_events_for_actor(actor)
assert event_found.title == event.title assert event_found.title == event.title
end end
test "get_public_events_for_actor/3", %{actor: actor, event: event} do test "list_public_events_for_actor/3", %{actor: actor, event: event} do
event1 = insert(:event, organizer_actor: actor) event1 = insert(:event, organizer_actor: actor)
case Events.get_public_events_for_actor(actor, 1, 10) do case Events.list_public_events_for_actor(actor, 1, 10) do
{:ok, events_found, 2} -> {:ok, events_found, 2} ->
event_ids = MapSet.new(events_found |> Enum.map(& &1.id)) event_ids = MapSet.new(events_found |> Enum.map(& &1.id))
assert event_ids == MapSet.new([event.id, event1.id]) assert event_ids == MapSet.new([event.id, event1.id])
@ -149,10 +146,10 @@ defmodule Mobilizon.EventsTest do
end end
end end
test "get_public_events_for_actor/3 with limited results", %{actor: actor, event: event} do test "list_public_events_for_actor/3 with limited results", %{actor: actor, event: event} do
event1 = insert(:event, organizer_actor: actor) event1 = insert(:event, organizer_actor: actor)
case Events.get_public_events_for_actor(actor, 1, 1) do case Events.list_public_events_for_actor(actor, 1, 1) do
{:ok, [%Event{id: event_found_id}], 2} -> {:ok, [%Event{id: event_found_id}], 2} ->
assert event_found_id in [event.id, event1.id] assert event_found_id in [event.id, event1.id]
@ -229,11 +226,6 @@ defmodule Mobilizon.EventsTest do
assert {:ok, %Tag{}} = Events.delete_tag(tag) assert {:ok, %Tag{}} = Events.delete_tag(tag)
assert_raise Ecto.NoResultsError, fn -> Events.get_tag!(tag.id) end assert_raise Ecto.NoResultsError, fn -> Events.get_tag!(tag.id) end
end end
test "change_tag/1 returns a tag changeset" do
tag = insert(:tag)
assert %Ecto.Changeset{} = Events.change_tag(tag)
end
end end
describe "tags_relations" do describe "tags_relations" do
@ -272,7 +264,7 @@ defmodule Mobilizon.EventsTest do
assert {:ok, %TagRelation{}} = Events.delete_tag_relation(tag_relation) assert {:ok, %TagRelation{}} = Events.delete_tag_relation(tag_relation)
end end
test "tag_neighbors/2 return the connected tags for a given tag", %{ test "list_tag_neighbors/2 return the connected tags for a given tag", %{
tag1: %Tag{} = tag1, tag1: %Tag{} = tag1,
tag2: %Tag{} = tag2 tag2: %Tag{} = tag2
} do } do
@ -307,7 +299,7 @@ defmodule Mobilizon.EventsTest do
}} = Events.create_tag_relation(%{tag_id: tag1.id, link_id: tag1.id}) }} = Events.create_tag_relation(%{tag_id: tag1.id, link_id: tag1.id})
# The order is preserved, since tag4 has one more relation than tag2 # The order is preserved, since tag4 has one more relation than tag2
assert [tag4, tag2] == Events.tag_neighbors(tag1) assert [tag4, tag2] == Events.list_tag_neighbors(tag1)
end end
end end
@ -383,10 +375,6 @@ defmodule Mobilizon.EventsTest do
test "delete_participant/1 deletes the participant", %{participant: participant} do test "delete_participant/1 deletes the participant", %{participant: participant} do
assert {:ok, %Participant{}} = Events.delete_participant(participant) assert {:ok, %Participant{}} = Events.delete_participant(participant)
end end
test "change_participant/1 returns a participant changeset", %{participant: participant} do
assert %Ecto.Changeset{} = Events.change_participant(participant)
end
end end
describe "sessions" do describe "sessions" do
@ -481,11 +469,6 @@ defmodule Mobilizon.EventsTest do
assert {:ok, %Session{}} = Events.delete_session(session) assert {:ok, %Session{}} = Events.delete_session(session)
assert_raise Ecto.NoResultsError, fn -> Events.get_session!(session.id) end assert_raise Ecto.NoResultsError, fn -> Events.get_session!(session.id) end
end end
test "change_session/1 returns a session changeset" do
session = insert(:session)
assert %Ecto.Changeset{} = Events.change_session(session)
end
end end
describe "tracks" do describe "tracks" do
@ -548,11 +531,6 @@ defmodule Mobilizon.EventsTest do
assert {:ok, %Track{}} = Events.delete_track(track) assert {:ok, %Track{}} = Events.delete_track(track)
assert_raise Ecto.NoResultsError, fn -> Events.get_track!(track.id) end assert_raise Ecto.NoResultsError, fn -> Events.get_track!(track.id) end
end end
test "change_track/1 returns a track changeset" do
track = insert(:track)
assert %Ecto.Changeset{} = Events.change_track(track)
end
end end
describe "comments" do describe "comments" do
@ -616,10 +594,5 @@ defmodule Mobilizon.EventsTest do
assert {:ok, %Comment{}} = Events.delete_comment(comment) assert {:ok, %Comment{}} = Events.delete_comment(comment)
assert_raise Ecto.NoResultsError, fn -> Events.get_comment!(comment.id) end assert_raise Ecto.NoResultsError, fn -> Events.get_comment!(comment.id) end
end end
test "change_comment/1 returns a comment changeset" do
comment = insert(:comment)
assert %Ecto.Changeset{} = Events.change_comment(comment)
end
end end
end end

View File

@ -113,7 +113,7 @@ defmodule Mobilizon.Service.ActivityPub.ActivityPubTest do
# TODO: The delete activity it relayed and fetched once again (and then not found /o\) # TODO: The delete activity it relayed and fetched once again (and then not found /o\)
test "it creates a delete activity and deletes the original event" do test "it creates a delete activity and deletes the original event" do
event = insert(:event) event = insert(:event)
event = Events.get_event_full_by_url!(event.url) event = Events.get_public_event_by_url_with_preload!(event.url)
{:ok, delete, _} = ActivityPub.delete(event) {:ok, delete, _} = ActivityPub.delete(event)
assert delete.data["type"] == "Delete" assert delete.data["type"] == "Delete"
@ -125,7 +125,7 @@ defmodule Mobilizon.Service.ActivityPub.ActivityPubTest do
test "it creates a delete activity and deletes the original comment" do test "it creates a delete activity and deletes the original comment" do
comment = insert(:comment) comment = insert(:comment)
comment = Events.get_comment_full_from_url!(comment.url) comment = Events.get_comment_from_url_with_preload!(comment.url)
{:ok, delete, _} = ActivityPub.delete(comment) {:ok, delete, _} = ActivityPub.delete(comment)
assert delete.data["type"] == "Delete" assert delete.data["type"] == "Delete"

View File

@ -46,13 +46,13 @@ defmodule MobilizonWeb.API.SearchTest do
test "search events" do test "search events" do
with_mock Events, with_mock Events,
find_and_count_events_by_name: fn "toto", 1, 10 -> build_events_by_name: fn "toto", 1, 10 ->
%Page{total: 1, elements: [%Event{title: "super toto event"}]} %Page{total: 1, elements: [%Event{title: "super toto event"}]}
end do end do
assert {:ok, %{total: 1, elements: [%Event{title: "super toto event"}]}} = assert {:ok, %{total: 1, elements: [%Event{title: "super toto event"}]}} =
Search.search_events("toto", 1, 10) Search.search_events("toto", 1, 10)
assert_called(Events.find_and_count_events_by_name("toto", 1, 10)) assert_called(Events.build_events_by_name("toto", 1, 10))
end end
end end
end end

View File

@ -197,7 +197,9 @@ defmodule MobilizonWeb.Resolvers.ReportResolverTest do
assert json_response(res, 200)["data"]["reports"] assert json_response(res, 200)["data"]["reports"]
|> Enum.map(fn report -> Map.get(report, "id") end) |> Enum.map(fn report -> Map.get(report, "id") end)
|> Enum.sort() == |> Enum.sort() ==
Enum.map([report_1_id, report_2_id, report_3_id], &to_string/1) [report_1_id, report_2_id, report_3_id]
|> Enum.map(&to_string/1)
|> Enum.sort()
query = """ query = """
{ {

View File

@ -39,9 +39,7 @@ defmodule MobilizonWeb.Resolvers.TagResolverTest do
|> Enum.map(fn tag -> tag["slug"] end) |> Enum.map(fn tag -> tag["slug"] end)
|> MapSet.new() == |> MapSet.new() ==
[tag2, tag3] [tag2, tag3]
|> Enum.map(fn |> Enum.map(fn tag -> tag.slug end)
tag -> tag.slug
end)
|> MapSet.new() |> MapSet.new()
end end
end end