<commit_before>import Argo
import Curry
import Runes

public struct ReadingLog: ResourceType {
  
  public let type: String
  public let id: String
  public let attributes: Attributes
  public let relationships: Relationships
  public let links: Links

  public struct Attributes {
    public let identifier: String
    public let cfi: String
    public let chapter: Int?
    public let duration: Int
    public let progress: Double // 0.0 ~ 1.0
    public let touchedAt: String?
    public let userAgent: String
    public let ip: String?
    public let latitude: Double?
    public let longitude: Double?
  }

  public struct Relationships {
    public let event: ResourceIdentifier
    public let parent: ResourceIdentifier?
    public let reading: ResourceIdentifier
  }

  public struct Links {
    public let selfLink: String
  }

}

extension ReadingLog: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<ReadingLog> {
    return curry(ReadingLog.init)
      <^> json <| "type"
      <*> json <| "id"
      <*> json <| "attributes"
      <*> json <| "relationships"
      <*> json <| "links"
  }
}

extension ReadingLog.Attributes: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<ReadingLog.Attributes> {
    let tmp1 = curry(ReadingLog.Attributes.init)
      <^> json <| "identifier"
      <*> json <| "cfi"
      <*> json <|? "chapter"
      <*> json <| "duration"
    
    let tmp2 = tmp1
      <*> json <| "progress"
      <*> json <|? "touched_at"
      <*> json <| "user_agent"
      <*> json <|? "ip"
    
    return tmp2
      <*> json <|? "latitude"
      <*> json <|? "longitude"
  }
}

extension ReadingLog.Relationships: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<ReadingLog.Relationships> {
    return curry(ReadingLog.Relationships.init)
      <^> json <| ["event", "data"]
      <*> json <|? ["parent", "data"]
      <*> json <| ["reading", "data"]
  }
}

extension ReadingLog.Links: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<ReadingLog.Links> {
    return curry(ReadingLog.Links.init)
      <^> json <| "self"
  }
}
<commit_msg>[Fix] 修正 ReadingLog 內 touchedAt 欄位<commit_after>import Argo
import Curry
import Runes

public struct ReadingLog: ResourceType {
  
  public let type: String
  public let id: String
  public let attributes: Attributes
  public let relationships: Relationships
  public let links: Links

  public struct Attributes {
    public let identifier: String
    public let cfi: String
    public let chapter: Int?
    public let duration: Int
    public let progress: Double // 0.0 ~ 1.0
    public let touchedAt: String
    public let userAgent: String
    public let ip: String?
    public let latitude: Double?
    public let longitude: Double?
  }

  public struct Relationships {
    public let event: ResourceIdentifier
    public let parent: ResourceIdentifier?
    public let reading: ResourceIdentifier
  }

  public struct Links {
    public let selfLink: String
  }

}

extension ReadingLog: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<ReadingLog> {
    return curry(ReadingLog.init)
      <^> json <| "type"
      <*> json <| "id"
      <*> json <| "attributes"
      <*> json <| "relationships"
      <*> json <| "links"
  }
}

extension ReadingLog.Attributes: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<ReadingLog.Attributes> {
    let tmp1 = curry(ReadingLog.Attributes.init)
      <^> json <| "identifier"
      <*> json <| "cfi"
      <*> json <|? "chapter"
      <*> json <| "duration"
    
    let tmp2 = tmp1
      <*> json <| "progress"
      <*> json <| "touched_at"
      <*> json <| "user_agent"
      <*> json <|? "ip"
    
    return tmp2
      <*> json <|? "latitude"
      <*> json <|? "longitude"
  }
}

extension ReadingLog.Relationships: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<ReadingLog.Relationships> {
    return curry(ReadingLog.Relationships.init)
      <^> json <| ["event", "data"]
      <*> json <|? ["parent", "data"]
      <*> json <| ["reading", "data"]
  }
}

extension ReadingLog.Links: Argo.Decodable {
  public static func decode(_ json: JSON) -> Decoded<ReadingLog.Links> {
    return curry(ReadingLog.Links.init)
      <^> json <| "self"
  }
}

{'fraction_non_alphanumeric': 0.12560834298957127, 'fraction_numerical': 0.0037079953650057938, 'mean_word_length': 2.9669117647058822, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 57, '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': '5692207', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1346, 'n_words': 389}