Skip to content

Commit

Permalink
[PERFORMANCE] [MER-3709] Streamline course section update application (
Browse files Browse the repository at this point in the history
…Simon-Initiative#5075)

* streamline

* stashing

* stashing

* stashing

* fix unreachable traverse

* cleanup warnings

* Auto format

---------

Co-authored-by: darrensiegel <[email protected]>
  • Loading branch information
darrensiegel and darrensiegel committed Sep 9, 2024
1 parent 0fc556e commit 896fc19
Show file tree
Hide file tree
Showing 5 changed files with 463 additions and 15 deletions.
8 changes: 6 additions & 2 deletions lib/oli/delivery/previous_next_index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule Oli.Delivery.PreviousNextIndex do
alias Oli.Delivery.Sections
alias Oli.Publishing.DeliveryResolver
alias Oli.Delivery.Hierarchy
alias Oli.Resources.Numbering
alias Oli.Repo

@doc """
Expand Down Expand Up @@ -127,8 +128,11 @@ defmodule Oli.Delivery.PreviousNextIndex do
"""
def rebuild(%Section{slug: slug} = section) do
case Repo.transaction(fn _ ->
DeliveryResolver.full_hierarchy(slug)
|> Hierarchy.build_navigation_link_map()
{new_hierarchy, _} =
DeliveryResolver.full_hierarchy(slug)
|> Numbering.renumber_hierarchy()

Hierarchy.build_navigation_link_map(new_hierarchy)
|> then(fn previous_next_index ->
Sections.update_section(section, %{previous_next_index: previous_next_index})
end)
Expand Down
4 changes: 2 additions & 2 deletions lib/oli/delivery/sections.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ defmodule Oli.Delivery.Sections do
# determine and return the list of page resource ids that are not reachable from that
# hierarchy, taking into account links from pages to other pages and the 'relates_to'
# relationship between pages.
defp determine_unreachable_pages(publication_ids, hierarchy_ids) do
def determine_unreachable_pages(publication_ids, hierarchy_ids) do
# Start with all pages
unreachable =
Oli.Publishing.all_page_resource_ids(publication_ids)
Expand Down Expand Up @@ -3593,7 +3593,7 @@ defmodule Oli.Delivery.Sections do
# For a given section resource, clean the children attribute to ensure that:
# 1. Any nil records are removed
# 2. All non-nil sr id references map to a non-deleted revision in the new pub
defp clean_children(section_resource, sr_id_to_resource_id, new_published_resources_map) do
def clean_children(section_resource, sr_id_to_resource_id, new_published_resources_map) do
updated_children =
section_resource.children
|> Enum.filter(fn child_id -> !is_nil(child_id) end)
Expand Down
Loading

0 comments on commit 896fc19

Please sign in to comment.