|
|
|
|
@ -26,16 +26,14 @@ final class MonthData : ModelObject, Storable { |
|
|
|
|
var femaleCount: Int? = nil |
|
|
|
|
var anonymousCount: Int? = nil |
|
|
|
|
var incompleteMode: Bool = false |
|
|
|
|
var dataModelIdentifier: String? |
|
|
|
|
var fileModelIdentifier: String? |
|
|
|
|
|
|
|
|
|
init(monthKey: String) { |
|
|
|
|
self.monthKey = monthKey |
|
|
|
|
self.creationDate = Date() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func _updateCreationDate() { |
|
|
|
|
self.creationDate = Date() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
required init(from decoder: Decoder) throws { |
|
|
|
|
let container = try decoder.container(keyedBy: CodingKeys.self) |
|
|
|
|
id = try container.decode(String.self, forKey: ._id) |
|
|
|
|
@ -47,6 +45,8 @@ final class MonthData : ModelObject, Storable { |
|
|
|
|
femaleCount = try container.decodeIfPresent(Int.self, forKey: ._femaleCount) |
|
|
|
|
anonymousCount = try container.decodeIfPresent(Int.self, forKey: ._anonymousCount) |
|
|
|
|
incompleteMode = try container.decodeIfPresent(Bool.self, forKey: ._incompleteMode) ?? false |
|
|
|
|
dataModelIdentifier = try container.decodeIfPresent(String.self, forKey: ._dataModelIdentifier) ?? nil |
|
|
|
|
fileModelIdentifier = try container.decodeIfPresent(String.self, forKey: ._fileModelIdentifier) ?? nil |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -69,7 +69,8 @@ final class MonthData : ModelObject, Storable { |
|
|
|
|
await MainActor.run { |
|
|
|
|
let lastDataSource = URL.importDateFormatter.string(from: fromDate) |
|
|
|
|
let currentMonthData : MonthData = DataStore.shared.monthData.first(where: { $0.monthKey == lastDataSource }) ?? MonthData(monthKey: lastDataSource) |
|
|
|
|
currentMonthData._updateCreationDate() |
|
|
|
|
currentMonthData.dataModelIdentifier = PersistenceController.getModelVersion() |
|
|
|
|
currentMonthData.fileModelIdentifier = fileURL?.fileModelIdentifier() |
|
|
|
|
currentMonthData.maleUnrankedValue = incompleteMode ? fftImportingMaleUnrankValue : lastDataSourceMaleUnranked?.0 |
|
|
|
|
currentMonthData.incompleteMode = incompleteMode |
|
|
|
|
currentMonthData.maleCount = incompleteMode ? fftImportingUncomplete : lastDataSourceMaleUnranked?.1 |
|
|
|
|
@ -97,5 +98,7 @@ final class MonthData : ModelObject, Storable { |
|
|
|
|
case _femaleCount = "femaleCount" |
|
|
|
|
case _anonymousCount = "anonymousCount" |
|
|
|
|
case _incompleteMode = "incompleteMode" |
|
|
|
|
case _dataModelIdentifier = "dataModelIdentifier" |
|
|
|
|
case _fileModelIdentifier = "fileModelIdentifier" |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|