<commit_before>class Bookmark < ActiveRecord::Base
  before_save :archive_the_url, :hash_url
  attr_accessible :desc, :private, :title, :url, :user_id, :tags, :hashed_url, :is_archived, :archive_url
  belongs_to :user
  has_many :tags, :dependent => :destroy

  validates_presence_of :url, :title, :user_id

  scope :published, -> { where(private: :nil) }
  scope :my_bookmarks, ->(user_id) { where(user_id: user_id) }
  # scope :published_or_mine,->(user_id) find_by_sql(.. UNION ..)
  scope :unpublished, -> { where(private: true) }
  scope :archived, -> { where(is_archived: true) }

  # download and archive the bookmark
  def archive_the_url
    if is_archived?
      logger.info "Queued the archiving of the url"
      Resque.enqueue(BookmarkArchiver, id)
    end
  end
 
  def hash_url<commit_msg>adds a default scope to bookmark model: most recently updated<commit_after>class Bookmark < ActiveRecord::Base
  before_save :archive_the_url, :hash_url
  attr_accessible :desc, :private, :title, :url, :user_id, :tags, :hashed_url, :is_archived, :archive_url
  belongs_to :user
  has_many :tags, :dependent => :destroy

  validates_presence_of :url, :title, :user_id

  # Set default order: most recently updated
  default_scope { order('updated_at DESC') }
  scope :published, -> { where(private: :nil) }
  scope :my_bookmarks, ->(user_id) { where(user_id: user_id) }
  # scope :published_or_mine,->(user_id) find_by_sql(.. UNION ..)
  scope :unpublished, -> { where(private: true) }
  scope :archived, -> { where(is_archived: true) }

  # download and archive the bookmark
  def archive_the_url
    if is_archived?
      logger.info "Queued the archiving of the url"
      Resque.enqueue(BookmarkArchiver, id)
    end
  end
 
  def hash_url
{'fraction_non_alphanumeric': 0.11855670103092783, 'fraction_numerical': 0.0, 'mean_word_length': 4.425465838509317, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1034244', 'n_tokens_mistral': 620, 'n_tokens_neox': 609, 'n_words': 155}