<% if @default_home_feed && user_signed_in? %>
  <% cache("fetched-home-articles-object", expires_in: 7.minutes) do %>
    <% @new_stories = Article.published.
         where("published_at > ? AND score > ?", rand(2..6).hours.ago, -15).
         limited_column_select.
         order("published_at DESC").
         limit(rand(15..80)).
         decorate %>
    <div id="followed-podcasts" data-episodes="<%= @podcast_episodes.to_json(include: { podcast: { only: %i[slug title id] } }) %>">
    </div>
    <div id="new-articles-object" data-articles="
      <%= @new_stories.to_json(
            only: %i[title path id user_id comments_count positive_reactions_count organization_id
                     reading_time video_thumbnail_url video video_duration_in_minutes language
                     experience_level_rating experience_level_rating_distribution cached_user cached_organization],
            methods: %i[readable_publish_date cached_tag_list_array flare_tag class_name
                        cloudinary_video_url video_duration_in_minutes published_at_int
                        published_timestamp],
          ) %>">
    </div>
    <div id="home-articles-object" data-articles="
      <%= @stories.to_json(
            only: %i[title path id user_id comments_count positive_reactions_count organization_id
                     reading_time video_thumbnail_url video video_duration_in_minutes language
                     experience_level_rating experience_level_rating_distribution cached_user cached_organization],
            methods: %i[readable_publish_date cached_tag_list_array flare_tag class_name
                        cloudinary_video_url video_duration_in_minutes published_at_int
                        published_timestamp],
          ) %>">
      <% 3.times do %>
        <div class="single-article single-article-small-pic">
          <div class="small-pic">
            <div class="color single-article-loading"></div>
          </div>
          <div class="content">
            <h3 class="single-article-loading">&nbsp;</h3>
          </div>
          <h4 class="single-article-loading" style="width:46%">
            &nbsp;
          </h4>
          <div class="tags single-article-loading" style="width:56%">
          </div>
        </div>
      <% end %>
    </div>
  <% end %>
<% else %>
  <% @stories.each_with_index do |story, i| %>
    <% next if story.id == @featured_story.id %>
    <% if !user_signed_in? && i == 4 %>
      <%= render "stories/sign_in_invitation" %>
    <% end %>
    <%= render "articles/single_story", story: story %>
  <% end %>
<% end %>
<% if @stories.size > 1 %>
  <div class="placeholder-div"></div>
<% end %>
<div class="single-article-small-pic" id="article-index-hidden-div" style="display:none"></div>
