<commit_before># frozen_string_literal: true
require_dependency 'backend/application_controller'

module Backend
  class VideoCollectionsController < ::Backend::ApplicationController
    load_and_authorize_resource

    before_action :set_video_collection, except: [:index, :new, :create, :paginate]
    before_action :set_video_collections, only: [:index, :edit, :new]
    before_action :set_objects, only: [:edit, :new]

    def index
    end

    def edit
      @videos = Video.where("album_id = ? OR album_id IS NULL", @video_collection.id).
        order(:title)
    end

    def update
      if @video_collection.update(video_collection_params)
        redirect_to edit_video_collection_url(@video_collection),
          notice: 'Video collection updated'
      else
        set_video_collections
        set_objects
        render :edit
      end
    end

    def new
      @videos = Video.order(:title)
    end

    def create
      @video_collection = VideoCollection.create(video_collection_params)
      if @video_collection.save
        redirect_to edit_video_collection_url(@video_collection),
          notice: 'Video collection created'
      else
        set_objects
        set_video_collections
        render :new<commit_msg>Only fetch videos without album<commit_after># frozen_string_literal: true
require_dependency 'backend/application_controller'

module Backend
  class VideoCollectionsController < ::Backend::ApplicationController
    load_and_authorize_resource

    before_action :set_video_collection, except: [:index, :new, :create, :paginate]
    before_action :set_video_collections, only: [:index, :edit, :new]
    before_action :set_objects, only: [:edit, :new]

    def index
    end

    def edit
      @videos = Video.where("album_id = ? OR album_id IS NULL", @video_collection.id).
        order(:title)
    end

    def update
      if @video_collection.update(video_collection_params)
        redirect_to edit_video_collection_url(@video_collection),
          notice: 'Video collection updated'
      else
        set_video_collections
        set_objects
        render :edit
      end
    end

    def new
      @videos = Video.not_in_album.order(:title)
    end

    def create
      @video_collection = VideoCollection.create(video_collection_params)
      if @video_collection.save
        redirect_to edit_video_collection_url(@video_collection),
          notice: 'Video collection created'
      else
        set_objects
        set_video_collections
        render :new
{'fraction_non_alphanumeric': 0.07344184200079397, 'fraction_numerical': 0.0, 'mean_word_length': 3.2140468227424748, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2768190', 'n_tokens_mistral': 719, 'n_tokens_neox': 702, 'n_words': 167}