You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: reading_list.rb
    path of file: ./repos/forem/app/services/search
    
    the code of the file until where you have to start completion: module Search
  class ReadingList
    ATTRIBUTES = [
      "articles.cached_tag_list",
      "articles.crossposted_at",
      "articles.path",
      "articles.published_at",
      "articles.reading_time",
      "articles.title",
      "articles.user_id",
      "reactions.id AS reaction_id",
      "reactions.user_id AS reaction_user_id",
    ].freeze
    REACTION_ATTRIBUTES = %i[id reactable_id user_id].freeze
    USER_ATTRIBUTES = %i[id name profile_image username].freeze

    DEFAULT_STATUSES = %w[confirmed valid].freeze

    DEFAULT_PER_PAGE = 60
    MAX_PER_PAGE = 100 # to avoid querying too many items, we set a maximum amount for a page

    # Search for the given user's reading list.
    #
    # @param user [User] whose reading list are we searching?
    # @param term [String] search term for the articles
    # @param statuses [Array<String>] what reading list status(es) to filter our search
    # @param tags [Array<String>] a list of tags to filter our search
    # @param page [Integer] the page in the pagination
    # @param per_page [Integer] how many items do we return in our pagination result set
    #
    # @return [Hash<Symb
    
    def self.find_articles(user:, term:, statuses:, tags:, page:, per_page:, only_published: true)
      # [@jgaskins, @rhymes] as `reactions` is potentially a big table, adding pagination
      # to an INNER JOIN (eg. `joins(:reactions)`) exponentially decreases the performance,
      # incrementing query time as the database has to scan all the rows just to discard
      # them right after if they lie outside the bounds of the `OFFSET`.
      # Even though it should have had a similar performance, we realized that a subquery
      # enabled PostgreSQL query planner to drastically decrease the planned time (ca. 145x)
      reaction_query_sql = user.reactions.readinglist
        .where(status: statuses, reactable_type: "Article")
        .order(created_at: :desc)
        .select(*REACTION_ATTRIBUTES)
        .to_sql

      relation = ::Article.joins(
        "INNER JOIN (#{reaction_query_sql}) reactions ON reactions.reactable_id = articles.id",
      )

      relation = relation.published if only_published

      relation = relation.search_articles(term) if term.present?

      relation = relation.cached_tagged_with(tags) if tags.any?

      # here we issue a COUNT(*) after all the conditions are applied,
      # because we need to fetch the total number of articles, pre pagination
      total = relation.count

      relation = relation.select(*ATTRIBUTES)
      relation = relation.page(page).per(per_page)

      {
        items: relation,
        total: total
      }
    end