comparison LazyBear/Views/Profile/ProfileView.swift @ 452:bb69f9d1d20f

Implement HomeView in WatchOS
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sat, 26 Jun 2021 18:45:31 +0200
parents 417148200aaf
children
comparison
equal deleted inserted replaced
451:bb130738b816 452:bb69f9d1d20f
94 94
95 /* 95 /*
96 Get symbols in watchlists (Core Data) -> Prepare url -> Request 96 Get symbols in watchlists (Core Data) -> Prepare url -> Request
97 */ 97 */
98 private func prepareUrl(_ requestType: RequestType) { 98 private func prepareUrl(_ requestType: RequestType) {
99 let symbols = watchlistCompanies.map { $0.symbol } 99 let symbols = Set(watchlistCompanies.map { $0.symbol })
100 100 let symbolsString = symbols.joined(separator:",")
101 var symbolString = ""
102 for (index, symbol) in symbols.enumerated() {
103 if index == 0 {
104 symbolString += symbol
105 } else {
106 symbolString += ",\(symbol)"
107 }
108 }
109 101
110 switch requestType { 102 switch requestType {
111 case .initial: 103 case .initial:
112 let url = "https://api.lazybear.app/profile/type=initial/symbols=\(symbolString)" 104 let url = "https://api.lazybear.app/profile/type=initial/symbols=\(symbolsString)"
113 profile.request(url, .initial) 105 profile.request(url, .initial)
114 106
115 default: 107 default:
116 let url = "https://api.lazybear.app/profile/type=streaming/symbols=\(symbolString)" 108 let url = "https://api.lazybear.app/profile/type=streaming/symbols=\(symbolsString)"
117 profile.request(url, .streaming) 109 profile.request(url, .streaming)
118 } 110 }
119 } 111 }
120 } 112 }
121 113