Store category groups as a list
Map complexity is of no use. Update JSON (stub).
This commit is contained in:
parent
807aca43fe
commit
027bf82208
|
@ -45,12 +45,12 @@ class ProviderPoolViewController: UIViewController {
|
|||
categories = infrastructure.categories.sorted { $0.name.lowercased() < $1.name.lowercased() }
|
||||
|
||||
for c in categories {
|
||||
sortedGroupsByCategory[c.name] = c.groups.values.sorted()
|
||||
sortedGroupsByCategory[c.name] = c.groups.sorted()
|
||||
}
|
||||
|
||||
// XXX: uglyyy
|
||||
for cat in categories {
|
||||
for group in cat.groups.values {
|
||||
for group in cat.groups {
|
||||
for p in group.pools {
|
||||
if p.id == currentPoolId {
|
||||
currentPool = p
|
||||
|
@ -88,15 +88,11 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate
|
|||
guard let sortedGroups = sortedGroupsByCategory[cat.name] else {
|
||||
continue
|
||||
}
|
||||
for entries in cat.groups.enumerated() {
|
||||
let group = entries.element.value
|
||||
for (j, group) in sortedGroups.enumerated() {
|
||||
guard let _ = group.pools.firstIndex(where: { $0.id == currentPool?.id }) else {
|
||||
continue
|
||||
}
|
||||
guard let row = sortedGroups.firstIndex(where: { $0.country == group.country && $0.area == group.area }) else {
|
||||
continue
|
||||
}
|
||||
return IndexPath(row: row, section: i)
|
||||
return IndexPath(row: j, section: i)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -28,5 +28,5 @@ import Foundation
|
|||
public struct PoolCategory: Codable {
|
||||
public let name: String
|
||||
|
||||
public let groups: [String: PoolGroup]
|
||||
public let groups: [PoolGroup]
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public struct Infrastructure: Codable {
|
|||
|
||||
public func pool(for identifier: String) -> Pool? {
|
||||
for cat in categories {
|
||||
for group in cat.groups.values {
|
||||
for group in cat.groups {
|
||||
guard let found = group.pools.first(where: { $0.id == identifier }) else {
|
||||
continue
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public struct Infrastructure: Codable {
|
|||
|
||||
public func pool(withPrefix prefix: String) -> Pool? {
|
||||
for cat in categories {
|
||||
for group in cat.groups.values {
|
||||
for group in cat.groups {
|
||||
guard let found = group.pools.first(where: { $0.id.hasPrefix(prefix) }) else {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue