0
     /ˆÔÓÒ509ÑÃÏ ý    /‹      Õ”ÍŽÚ0…÷ó®Ý%7Úé0Nª)A*ˆ¡ªªª'v°Õ$Žl¥O_‡ÁTƒÚ.ú·ˆr�û~çD¹äY2­>,Æèíê~ŠïÞL'#„=€÷ý@²JÚ?Æ3Œ°°¶ìv;×÷•^Ãj	Â–Å ŒÕ2³>³ÇW¤y_!"8eîŽˆ•¶àñ¤büR9µ±F2Þ;ÀTiÀðŠå²à>ã¥ò…ñ3¥j×€©ÌxÆGµk·7Àø2A5„¯n†„^0ý ˜–[®¡TlSðne´Ž	:(’*¶oXÃ¿ÊåÚ¢é¯)uL¬@[ZÈua«jY®‘ÑY„Afª2�´úì¯eŽ-l„?NFóONV4»cB‘Ð<�ðëQ4»�G	Žg´äèÓš{§¹Ãñ”‹¢Ì%gÅ­øA~½|`Òjn2-k+Uu’‚³xn5S…©©óúÂ9ú\ÕJØ�Ò Ù£0wËñl•L–m$¬9âD÷ç¾2ŽTóÊ¢DjžY¥÷]-Ñó*5õíq‰:‹Z®…Å1BzRù¹äª`\Ÿ's)6&ŠMê˜�Õ9ëwp½ ÷ÒC¯ ðz8¸Fèrá®ÎESýÇ.rsòáêßïä'ÿIè¦�Ã%ÐÎûoYë+~R        1ˆ¾‘äÇò 8àGâÏ?(¿ŸÌƒh¹ÒÃÏ      1auto
  4   3ˆl–Ým_JÕ4Ò‚ € ™¸Ó7 1hß�þD ,ØÛ(�§€øüÿÍ‚l"ÓÄÐ      3
################################################
## fBonds
################################################


################################################
## import name space
################################################

import("timeDate")
import("timeSeries")
import("fBasics")

importFrom("graphics", contour, grid, image, persp, title)
importFrom("stats", nlminb)


################################################
## functions
################################################

exportPattern(".")


  5   5ˆl–äY>” ”¾R( 	ÅýÁàS�ÿ�þB gãyÒÊ'„×óÎƒh¹ÔÅÑ      5      27        0     2080        6        0        0        0        0        0        0        6        0        0        0        0        0        0
     7ˆÀ�äÇò 8àGâ �ùÎƒh¹ÔÅÑ      70
  M   9ˆl–ß=¿Jå2ÛR‚ œPA¸&n41hß�þB!gié6š
÷óÏƒiÆÅÕÎa–äY>” ”¾R( 	ÅýÁ3p S�ÿÓ ,    9# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

class DataPrivacyTask < ApplicationModel
  include HasDefaultModelUserRelations

  include DataPrivacyTask::HasActivityStreamLog
  include ChecksClientNotification

  scope :failed,     -> { where(state: 'failed') }
  scope :in_process, -> { where(state: 'in process') }
  scope :completed,  -> { where(state: 'completed') }

  store :preferences

  # optional because related data will get deleted and it would
  # cause validation errors if e.g. the created_by_id of the task
  # would need to get mapped by a deletion
  belongs_to :deletable, polymorphic: true, optional: true

  before_create :prepare_deletion_preview

  validates_with Validations::DataPrivacyTaskValidator

  MAX_PREVIEW_TICKETS = 1000

  def perform
    perform_deletable
    update!(state: 'completed')
  rescue => e
    handle_exception(e)
  end

  def self.cleanup(diff = 12.months)
    where(created_at: ...diff.ago)
      .destroy_all

    true
  end

  def prepare_deletion_preview
    prepare_deletion_preview_tickets
    prepare_deletion_preview_user
    prepare_deletion_preview_organization
    prepare_deletion_preview_anonymize
  end

  def deletion_counts
    preferences.slice(:owner_tickets_count, :customer_tickets_count)
  end

  private

  # set user inactive before destroy to prevent
  # new online notifications or other events while
  # the deletion process is running
  # https://github.com/zammad/zammad/issues/3942
  def update_inactive(object)
    object.update(active: false)
  end

  def perform_deletable
    return if !deletable_type.constantize.exists?(id: deletable_id)

    prepare_deletion_preview
    save!

    case deletable
    when User
      perform_user_or_organization
    when Ticket
      perform_ticket
    end
  end

  def perform_user_or_organization
    if delete_organization?
      perform_organization(deletable.organization)

      return
    end

    perform_user
  end

  def perform_organization(organization)
    update_inactive(organization)
    organization.members.find_each { |user| update_inactive(user) }
    organization.destroy_dependent_associations
    organization.destroy(associations: true)
  end

  def perform_user
    update_inactive(deletable)
    deletable.destroy_dependent_associations
    deletable.destroy
  end

  def perform_ticket
    deletable.destroy
  end

  def handle_exception(e)
    Rails.logger.error e
    preferences[:error] = "ERROR: #{e.inspect}"
    self.state = 'failed'
    save!
  end

  def delete_