Skip to content

Commit

Permalink
#18: All of the Importer's *ByID arrays now just take regular Int key…
Browse files Browse the repository at this point in the history
…s, not Int16s and Int64s.
  • Loading branch information
jrtibbetts committed May 14, 2019
1 parent e6b0405 commit fa673df
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class DiscogsCollectionImporter: NSManagedObjectContext {

}

public typealias CoreDataFieldsByID = [Int16: CustomField]
public typealias CoreDataFieldsByID = [Int: CustomField]

public typealias CoreDataFoldersByID = [Int64: Folder]
public typealias CoreDataFoldersByID = [Int: Folder]

public typealias CoreDataItemsByID = [Int64: CollectionItem]
public typealias CoreDataItemsByID = [Int: CollectionItem]

// MARK: - Properties

Expand Down Expand Up @@ -67,7 +67,7 @@ public class DiscogsCollectionImporter: NSManagedObjectContext {
}.then { (coreDataFoldersByID) -> Promise<[CollectionFolderItem]> in
let masterFolderID = 0

guard let masterFolder = coreDataFoldersByID[Int64(masterFolderID)] else {
guard let masterFolder = coreDataFoldersByID[masterFolderID] else {
throw ImportError.noAllFolderWasFound
}
self.importerDelegate?.update(importedItemCount: 4, totalCount: 6, forService: self.service)
Expand Down Expand Up @@ -106,7 +106,7 @@ public class DiscogsCollectionImporter: NSManagedObjectContext {
}

let coreDataField = try CustomField.fetchOrCreateEntity(fromDiscogsField: discogsField, inContext: self)
coreDataFieldsByID[Int16(discogsField.id)] = coreDataField
coreDataFieldsByID[discogsField.id] = coreDataField
}

seal.fulfill(coreDataFieldsByID)
Expand All @@ -128,7 +128,7 @@ public class DiscogsCollectionImporter: NSManagedObjectContext {
folder.update(withDiscogsFolder: discogsFolder)
}

coreDataFoldersByID[coreDataFolder.folderID] = coreDataFolder
coreDataFoldersByID[discogsFolder.id] = coreDataFolder
}

seal.fulfill(coreDataFoldersByID)
Expand Down Expand Up @@ -175,7 +175,7 @@ public class DiscogsCollectionImporter: NSManagedObjectContext {
item.update(withDiscogsItem: discogsItem, inContext: self)
}

coreDataItemsByID[Int64(discogsItem.id)] = coreDataItem
coreDataItemsByID[discogsItem.id] = coreDataItem
}

seal.fulfill(coreDataItemsByID)
Expand All @@ -184,7 +184,7 @@ public class DiscogsCollectionImporter: NSManagedObjectContext {

func addCoreDataItemsToOtherFolders(forUserName userName: String) -> Promise<Void> {
let folderPromises: [Promise<Void>] = discogsFolders.filter { $0.id != 0 }.map { (discogsFolder) -> Promise<Void> in
guard let coreDataFolder = self.coreDataFoldersByID[Int64(discogsFolder.id)] else {
guard let coreDataFolder = self.coreDataFoldersByID[discogsFolder.id] else {
return Promise<Void>()
}

Expand All @@ -195,7 +195,7 @@ public class DiscogsCollectionImporter: NSManagedObjectContext {
var coreDataItemCount = 0

discogsItems.forEach { (discogsItem) in
if let coreDataItem = self.coreDataItemsByID[Int64(discogsItem.id)] {
if let coreDataItem = self.coreDataItemsByID[discogsItem.id] {
print(" [\(coreDataItemCount + 1)] \(discogsItem.basicInformation!.title) (\(discogsItem.id))")
coreDataItem.addToFolders(coreDataFolder)
coreDataItemCount += 1
Expand Down

0 comments on commit fa673df

Please sign in to comment.