<commit_before>//
//  HomeViewModel.swift
//  PennMobile
//
//  Created by <NAME> on 1/17/18.
//  Copyright © 2018 PennLabs. All rights reserved.
//

import Foundation
import UIKit

protocol HomeViewModelDelegate: HomeCellDelegate {}

class HomeTableViewModel: ModularTableViewModel {}

// MARK: - Preload Webview
extension HomeTableViewModel {
    func venueToPreload() -> DiningVenue? {
        let diningItems = self.items.filter { $0.cellIdentifier == HomeDiningCell.identifier }
        guard let diningItem = diningItems.first as? HomeDiningCellItem else { return nil }
        return diningItem.venues.first
    }
    
    func getItems(for itemTypes: [HomeCellItem.Type]) -> [HomeCellItem] {
        guard let allItems = self.items as? [HomeCellItem] else { return [] }
        let items = allItems.filter { (item) -> Bool in
            return itemTypes.contains(where: { (itemType) -> Bool in
                return itemType.jsonKey == type(of: item).jsonKey
            })
        }
        return items
    }
}

// MARK: - UITableViewDelegate + Tracking
extension HomeTableViewModel {
    func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        let item = items[indexPath.row]
        let cellType = type(of: item) as! HomeCellItem.Type
        var id: String? = nil
        if let identifiableItem = item as? LoggingIdentifiable {
            id = identifiableItem.id
        }
        
        let cellTypeStr: String
        if let testableItem = item as? FeedTestable, testableItem.isTest {
            cellTypeStr = "\(cellType.jsonKey)-test"
        } else {
            cellTypeStr = cellType.jsonKey
        }
        FeedAnalyticsManager.shared.track(cellType: cellTypeStr, index: indexPath.row, id: id, batchSize: items.count)
    }
}<commit_msg>changed test cell type str<commit_after>//
//  HomeViewModel.swift
//  PennMobile
//
//  Created by <NAME> on 1/17/18.
//  Copyright © 2018 PennLabs. All rights reserved.
//

import Foundation
import UIKit

protocol HomeViewModelDelegate: HomeCellDelegate {}

class HomeTableViewModel: ModularTableViewModel {}

// MARK: - Preload Webview
extension HomeTableViewModel {
    func venueToPreload() -> DiningVenue? {
        let diningItems = self.items.filter { $0.cellIdentifier == HomeDiningCell.identifier }
        guard let diningItem = diningItems.first as? HomeDiningCellItem else { return nil }
        return diningItem.venues.first
    }
    
    func getItems(for itemTypes: [HomeCellItem.Type]) -> [HomeCellItem] {
        guard let allItems = self.items as? [HomeCellItem] else { return [] }
        let items = allItems.filter { (item) -> Bool in
            return itemTypes.contains(where: { (itemType) -> Bool in
                return itemType.jsonKey == type(of: item).jsonKey
            })
        }
        return items
    }
}

// MARK: - UITableViewDelegate + Tracking
extension HomeTableViewModel {
    func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        let item = items[indexPath.row]
        let cellType = type(of: item) as! HomeCellItem.Type
        var id: String? = nil
        if let identifiableItem = item as? LoggingIdentifiable {
            id = identifiableItem.id
        }
        
        let cellTypeStr: String
        if let testableItem = item as? FeedTestable, testableItem.isTest {
            cellTypeStr = "test-\(cellType.jsonKey)"
        } else {
            cellTypeStr = cellType.jsonKey
        }
        FeedAnalyticsManager.shared.track(cellType: cellTypeStr, index: indexPath.row, id: id, batchSize: items.count)
    }
}
{'fraction_non_alphanumeric': 0.09534186870062654, 'fraction_numerical': 0.005448106782892944, 'mean_word_length': 2.589442815249267, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3861836', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1031, 'n_words': 280}