<commit_before>//
//  SubscriptionManager.swift
//  Rocket.Chat
//
//  Created by <NAME> on 7/9/16.
//  Copyright © 2016 Rocket.Chat. All rights reserved.
//

import Foundation
import RealmSwift

class SubscriptionManager {
    
    static func updateSubscriptions(auth: Auth, completion: MessageCompletion) {
        let request = [
            "msg": "method",
            "method": "subscriptions/get",
            "params": []
        ]

        SocketManager.sendMessage(request) { (response) in
            guard !response.isError() else {
                return print(response.result)
            }
            
            let subscriptions = List<Subscription>()
            if let result = response.result["result"].array {
                for obj in result {
                    let subscription = Subscription()
                    subscription.identifier = obj["_id"].string!
                    subscription.rid = obj["rid"].string!
                    subscription.unread = obj["unread"].int ?? 0
                    subscription.open = obj["open"].bool ?? false
                    subscription.alert = obj["alert"].bool ?? false
                    subscriptions.append(subscription)
                }
            }
            
            let realm = try! Realm()
            try! realm.write {
                realm.add(subscriptions, update: true)
                auth.subscriptions = subscriptions
            }
            
            completion(response)
        }
    }
    
}
<commit_msg>Save subscription name<commit_after>//
//  SubscriptionManager.swift
//  Rocket.Chat
//
//  Created by <NAME> on 7/9/16.
//  Copyright © 2016 Rocket.Chat. All rights reserved.
//

import Foundation
import RealmSwift

class SubscriptionManager {
    
    static func updateSubscriptions(auth: Auth, completion: MessageCompletion) {
        let request = [
            "msg": "method",
            "method": "subscriptions/get",
            "params": []
        ]

        SocketManager.sendMessage(request) { (response) in
            guard !response.isError() else {
                return print(response.result)
            }
            
            let subscriptions = List<Subscription>()
            if let result = response.result["result"].array {
                for obj in result {
                    let subscription = Subscription()
                    subscription.identifier = obj["_id"].string!
                    subscription.rid = obj["rid"].string!
                    subscription.name = obj["name"].string!
                    subscription.unread = obj["unread"].int ?? 0
                    subscription.open = obj["open"].bool ?? false
                    subscription.alert = obj["alert"].bool ?? false
                    subscriptions.append(subscription)
                }
            }
            
            let realm = try! Realm()
            try! realm.write {
                realm.add(subscriptions, update: true)
                auth.subscriptions = subscriptions
            }
            
            completion(response)
        }
    }
    
}

{'fraction_non_alphanumeric': 0.10325911584382058, 'fraction_numerical': 0.005808325266214908, 'mean_word_length': 1.4409448818897639, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 7, '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': '1456217', 'n_tokens_mistral': 766, 'n_tokens_neox': 735, 'n_words': 168}