<commit_before>//
//  Placement+Records.swift
//  AdButler
//
//  Created by <NAME> on 11/20/16.
//  Copyright © 2016 AdButler. All rights reserved.
//

import Foundation

public extension Placement {
    public func recordImpression() {
        if let accupixelUrl = self.accupixelUrl.map({ URL(string: $0) }), let url = accupixelUrl {
            AdButler.requestPixel(with: url)
        } else if let trackingPixel = self.trackingPixel.map({ URL(string: $0) }), let url = trackingPixel {
            AdButler.requestPixel(with: url)
        } else {
            print("Cannot construct a valid impression URL.")
        }
    }
    
    public func recordClick() {
        if let redirectUrl = self.redirectUrl.map({ URL(string: $0) }), let url = redirectUrl {
            AdButler.requestPixel(with: url)
        } else {
            print("Cannot construct a valid redirect URL.")
        }
    }
}
<commit_msg>Use flatMap to avoid nested Optional types<commit_after>//
//  Placement+Records.swift
//  AdButler
//
//  Created by <NAME> on 11/20/16.
//  Copyright © 2016 AdButler. All rights reserved.
//

import Foundation

public extension Placement {
    public func recordImpression() {
        if let accupixelUrl = self.accupixelUrl.flatMap({ URL(string: $0) }) {
            AdButler.requestPixel(with: accupixelUrl)
        } else if let trackingPixel = self.trackingPixel.flatMap({ URL(string: $0) }) {
            AdButler.requestPixel(with: trackingPixel)
        } else {
            print("Cannot construct a valid impression URL.")
        }
    }
    
    public func recordClick() {
        if let redirectUrl = self.redirectUrl.flatMap({ URL(string: $0) }) {
            AdButler.requestPixel(with: redirectUrl)
        } else {
            print("Cannot construct a valid redirect URL.")
        }
    }
}

{'fraction_non_alphanumeric': 0.11487964989059081, 'fraction_numerical': 0.014223194748358862, 'mean_word_length': 2.3074141048824592, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5513592', 'n_tokens_mistral': 549, 'n_tokens_neox': 531, 'n_words': 145}