<commit_before>package com.komanov.serialization.domain

import java.time.Instant
import java.util.UUID

object EventProcessor {
  
  private val nullInstant = Instant.ofEpochMilli(0)
  private val nullSite = Site(null, null, 0, null, Nil, null, null, Nil, Nil, Nil, Nil, published = false, nullInstant, nullInstant)

  def apply(list: Seq[SiteEventData]): Site = {
    list.foldLeft(nullSite) {
      case (s, SiteEventData(_, SiteCreated(id, ownerId, siteType), dateCreated)) =>
        s.copy(id = id, ownerId = ownerId, siteType = siteType, dateCreated = dateCreated)

      case (s, SiteEventData(_, SiteRevisionSet(rev), dateUpdated)) =>
        s.copy(revision = rev, dateUpdated = dateUpdated)

      case (s, SiteEventData(_, SiteNameSet(name), _)) =>
        s.copy(name = name)

      case (s, SiteEventData(_, SiteDescriptionSet(description), _)) =>
        s.copy(description = description)

      case (s, SiteEventData(_, SitePublished(), _)) =>
        s.copy(published = true)

      case (s, SiteEventData(_, SiteUnpublished(), _)) =>
        s.copy(published = false)

      case (s, SiteEventData(_, SiteFlagAdded(flag), _)) =>
        s.copy(flags = Set(s.flags: _*).+(flag).toSeq)

      case (s, SiteEventData(_, SiteFlagRemoved(flag), _)) =>
        s.copy(flags = Set(s.flags: _*).-(flag).toSeq)

      case (s, SiteEventData(_, DomainAdded(name), _)) =>
        s.copy(domains = s.domains :+ Domain(name, primary = false))

      case (s, SiteEventData(_, PrimaryDomainSet(name), _)) =>
        s.copy(domains = s.domains.map(d => if (d.name == name) d.copy(primary = true) else d))

      case (s, SiteEventData(_, DomainRemoved(name), _)) =>
        s.copy(domains = s.domains.filter(_.name != name))

      case (s, SiteEventData(_, DefaultMetaTagAdded(name, value), _)) =>
        s.copy(defaultMetaTags = s.defaultMetaTags :+ MetaTag(name, value))

      case (s, SiteEventData(_, DefaultMetaTagRemoved(name), _)) =>
        s.copy(defaultMetaTags = s.defaultMetaTags.filter(_.name != name))

      case (s, SiteEventData(_, PageAdded(path), _)) =>
        s.pages.find(_.path == path).fold(s.copy(pages = s.pages :+ Page(null, path, Nil, Nil)))(_ => s)

      case (s, SiteEventData(_, PageNameSet(path, name), _)) =>
        modifyPage(s, path, p => p.copy(name = name))
<commit_msg>Fix inexhaustive match<commit_after>package com.komanov.serialization.domain

import java.time.Instant
import java.util.UUID

object EventProcessor {
  
  private val nullInstant = Instant.ofEpochMilli(0)
  private val nullSite = Site(null, null, 0, null, Nil, null, null, Nil, Nil, Nil, Nil, published = false, nullInstant, nullInstant)

  def apply(list: Seq[SiteEventData]): Site = {
    list.foldLeft(nullSite) {
      case (s, SiteEventData(_, SiteCreated(id, ownerId, siteType), dateCreated)) =>
        s.copy(id = id, ownerId = ownerId, siteType = siteType, dateCreated = dateCreated)

      case (s, SiteEventData(_, SiteRevisionSet(rev), dateUpdated)) =>
        s.copy(revision = rev, dateUpdated = dateUpdated)

      case (s, SiteEventData(_, SiteNameSet(name), _)) =>
        s.copy(name = name)

      case (s, SiteEventData(_, SiteDescriptionSet(description), _)) =>
        s.copy(description = description)

      case (s, SiteEventData(_, SitePublished(), _)) =>
        s.copy(published = true)

      case (s, SiteEventData(_, SiteUnpublished(), _)) =>
        s.copy(published = false)

      case (s, SiteEventData(_, SiteFlagAdded(flag), _)) =>
        s.copy(flags = Set(s.flags: _*).+(flag).toSeq)

      case (s, SiteEventData(_, SiteFlagRemoved(flag), _)) =>
        s.copy(flags = Set(s.flags: _*).-(flag).toSeq)

      case (s, SiteEventData(_, DomainAdded(name), _)) =>
        s.copy(domains = s.domains :+ Domain(name, primary = false))

      case (s, SiteEventData(_, PrimaryDomainSet(name), _)) =>
        s.copy(domains = s.domains.map(d => if (d.name == name) d.copy(primary = true) else d))

      case (s, SiteEventData(_, DomainRemoved(name), _)) =>
        s.copy(domains = s.domains.filter(_.name != name))

      case (s, SiteEventData(_, DefaultMetaTagAdded(name, value), _)) =>
        s.copy(defaultMetaTags = s.defaultMetaTags :+ MetaTag(name, value))

      case (s, SiteEventData(_, DefaultMetaTagRemoved(name), _)) =>
        s.copy(defaultMetaTags = s.defaultMetaTags.filter(_.name != name))

      case (s, SiteEventData(_, PageAdded(path), _)) =>
        s.pages.find(_.path == path).fold(s.copy(pages = s.pages :+ Page(null, path, Nil, Nil)))(_ => s)

      case (s, SiteEventData(_, PageRemoved(path), _)) =>
        s.pages.find(_.path == path).fold(s.copy(pages = s.pages.filter(_.path != path)))(_ => s)

      case (s, SiteEventData(_, PageNameSet(path, name), _)) =>
        modifyPage(s, path, p => p.copy(name = name))

{'fraction_non_alphanumeric': 0.16215089620675283, 'fraction_numerical': 0.0008336807002917883, 'mean_word_length': 3.455896007428041, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '3869053', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1569, 'n_words': 339}