Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive execution? #21

Open
davidw opened this issue Oct 16, 2023 · 4 comments
Open

Recursive execution? #21

davidw opened this issue Oct 16, 2023 · 4 comments

Comments

@davidw
Copy link

davidw commented Oct 16, 2023

    def dump_belongs_to_associations!
      belongs_to_reflections.map do |reflection|
        next if to_load_map[reflection.name].empty?
        RelationDumper.new(
          build_relation(reflection),
          root_dumper,
          "#{association_path}.#{reflection.name}",
          search_key:       reflection.association_primary_key,
          identifiers:      to_load_map[reflection.name],
          limitable:        false,
        ).call
      end
    end

From RelationDumper - to me it seems like this is recursive, which might cause some resource issues in a larger DB with a lot of relationships.

@Envek
Copy link
Member

Envek commented Oct 17, 2023

AFAIR I made it to be able to dump tree-like structures stored in HABTM. So you can choose parent records and get all their descendants.

@davidw
Copy link
Author

davidw commented Oct 21, 2023

@Envek right, but it might make sense to put things into a queue and then run that...? It's holding open a lot of resources, I think, when it goes into deeply nested stuff.

@davidw
Copy link
Author

davidw commented Oct 21, 2023

Maybe there's something else going on... it seems to keep picking up the same models via various associations. I'm dumping the associaton path and get stuff like

xxxxxxxxxxxxxxxxxxxxxx.yyyyyyyyyyyyyyyyyyyyyy_custom_elements.yyyyyyyyyyyyyyyyyyyyyy.agents.user.yyyyyyyyyyyyyyyyyyyyyy.agents.office_memberships.office.aaaaaaaaaaaaaaaaaas.zzzzzzzzzzzzzzzzzzzzzz.neighborhood.geography_similarities.similar_geography.geography_similarities.similar_geography.geography_similarities.similar_geography.geography_similarities.similar_geography.geography_similarities.similar_geography.geography_similarities.similar_geography.zzzzzzzzzzzzzzzzzzzzzz_geographies.zzzzzzzzzzzzzzzzzzzzzz.notes.user.yyyyyyyyyyyyyyyyyyyyyy.agents.user.yyyyyyyyyyyyyyyyyyyyyy.agents.user.yyyyyyyyyyyyyyyyyyyyyy.client_website.yyyyyyyyyyyyyyyyyyyyyy.agents.user.search_states.visual_report.user.yyyyyyyyyyyyyyyyyyyyyy.client_website.client_website_employees.clientwebsiteemployees_agents.agent.user.search_states.shareables.recipient.notifications.sender.search_states.shareables.recipient.received_shareables.bbbbbbbbbbbbbbbb_client.list.bbbbbbbbbbbbbbbb_clients.client.search_states.shareables.recipient.notifications.sender.yyyyyyyyyyyyyyyyyyyyyy.agents.user.yyyyyyyyyyyyyyyyyyyyyy.agents.user.search_states.shareables.recipient.notifications.sender.yyyyyyyyyyyyyyyyyyyyyy.agents.user.yyyyyyyyyyyyyyyyyyyyyy.agents.user.notifications.sender.received_invitations.user.user_privileges.privilege.user_privileges.user.yyyyyyyyyyyyyyyyyyyyyy.client_website.client_website_employees.clientwebsiteemployees_client_website_employee_teams.client_website_employee_team.clientwebsiteemployeeteams_client_website_zzzzzzzzzzzzzzzzzzzzzzs.client_website_zzzzzzzzzzzzzzzzzzzzzz.zzzzzzzzzzzzzzzzzzzzzz.neighborhood.geography_similarities.similar_geography.geography_similarities.similar_geography.zzzzzzzzzzzzzzzzzzzzzz_geographies.zzzzzzzzzzzzzzzzzzzzzz.aaaaaaaaaaaaaaaaaas.neighborhood.geography_similarities.similar_geography.zzzzzzzzzzzzzzzzzzzzzz_geographies.zzzzzzzzzzzzzzzzzzzzzz.neighborhood.geography_similarities.similar_geography.geography_similarities.similar_geography.zzzzzzzzzzzzzzzzzzzzzz_geographies.zzzzzzzzzzzzzzzzzzzzzz.neighborhood.geography_similarities.similar_geography.zzzzzzzzzzzzzzzzzzzzzz_geographies.zzzzzzzzzzzzzzzzzzzzzz.neighborhood.geography_similarities.similar_geography.zzzzzzzzzzzzzzzzzzzzzz_geographies.zzzzzzzzzzzzzzzzzzzzzz.aaaaaaaaaaaaaaaaaas.neighborhood.geography_similarities.similar_geography.zzzzzzzzzzzzzzzzzzzzzz_geographies.zzzzzzzzzzzzzzzzzzzzzz.neighborhood.geography_similarities.similar_geography.zzzzzzzzzzzzzzzzzzzzzz_geographies.zzzzzzzzzzzzzzzzzzzzzz.aaaaaaaaaaaaaaaaaas.yyyyyyyyyyyyyyyyyyyyyy.agents.common_agent.agents.user.notifications.sender.notifications.sender.received_invitations.user.bbbbbbbbbbbbbbbb_clients.client.sent_notifications.user.subscriptions.plan.subscriptions.user.search_states.shareables.recipient.received_shareables.bbbbbbbbbbbbbbbb_client.list.bbbbbbbbbbbbbbbb_clients.client.notifications.sender.notifications.sender.search_states.shareables.recipient.received_shareables.bbbbbbbbbbbbbbbb_client.list.bbbbbbbbbbbbbbbb_clients.client.notifications.sender.search_states.shareables.recipient.received_shareables.bbbbbbbbbbbbbbbb_client.list.bbbbbbbbbbbbbbbb_clients.client.notifications.sender.search_states.shareables.recipient.received_shareables.bbbbbbbbbbbbbbbb_client.list.bbbbbbbbbbbbbbbb_clients.client.notifications.sender.subscriptions.plan.subscriptions.user.yyyyyyyyyyyyyyyyyyyyyy.agents.common_agent.agents.aaaaaaaaaaaaaaaaaa_agents.aaaaaaaaaaaaaaaaaa.zzzzzzzzzzzzzzzzzzzzzz.aaaaaaaaaaaaaaaaaas.yyyyyyyyyyyyyyyyyyyyyy.agents.common_agent.agents.yyyyyyyyyyyyyyyyyyyyyy.agents.common_agent.agents.yyyyyyyyyyyyyyyyyyyyyy.agents.common_agent.agents.yyyyyyyyyyyyyyyyyyyyyy.agents.common_agent.agents.office_memberships.office.office_memberships.agent.common_agent.agents.yyyyyyyyyyyyyyyyyyyyyy.agents.common_agent.agents.yyyyyyyyyyyyyyyyyyyyyy.agents.common_agent.agents.aaaaaaaaaaaaaaaaaa_agents.aaaaaaaaaaaaaaaaaa.zzzzzzzzzzzzzzzzzzzzzz.aaaaaaaaaaaaaaaaaas.yyyyyyyyyyyyyyyyyyyyyy.agents.common_agent.agents.aaaaaaaaaaaaaaaaaa_agents.aaaaaaaaaaaaaaaaaa.zzzzzzzzzzzzzzzzzzzzzz.aaaaaaaaaaaaaaaaaas

@Envek
Copy link
Member

Envek commented Jun 20, 2024

Hey, just a heads up that there is a new option limit_deep to limit association depth from #13, hope that it can help in any way.

EvilSeed.configure do |config|
  config.root('Forum', featured: true) do |root|
    # Limit the depth of associations to be dumped from the root level
    # All traverses through has_many, belongs_to, etc are counted
    # So forum.subforums.subforums.questions.answers will be 5 levels deep
    root.limit_deep(10)
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants