MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / getGuideNumberPMS

Function getGuideNumberPMS

src/hdhr.go:184–236  ·  view source on GitHub ↗
(channelName string)

Source from the content-addressed store, hash-verified

182}
183
184func getGuideNumberPMS(channelName string) (pmsID string, err error) {
185
186 if len(Data.Cache.PMS) == 0 {
187
188 Data.Cache.PMS = make(map[string]string)
189
190 pms, err := loadJSONFileToMap(System.File.PMS)
191
192 if err != nil {
193 return "", err
194 }
195
196 for key, value := range pms {
197 Data.Cache.PMS[key] = value.(string)
198 }
199
200 }
201
202 var getNewID = func(channelName string) (id string) {
203
204 var i int
205
206 newID:
207
208 var ids []string
209 id = fmt.Sprintf("id-%d", i)
210
211 for _, v := range Data.Cache.PMS {
212 ids = append(ids, v)
213 }
214
215 if indexOfString(id, ids) != -1 {
216 i++
217 goto newID
218 }
219
220 return
221 }
222
223 if value, ok := Data.Cache.PMS[channelName]; ok {
224
225 pmsID = value
226
227 } else {
228
229 pmsID = getNewID(channelName)
230 Data.Cache.PMS[channelName] = pmsID
231 saveMapToJSONFile(System.File.PMS, Data.Cache.PMS)
232
233 }
234
235 return
236}

Callers 1

getLineupFunction · 0.85

Calls 3

loadJSONFileToMapFunction · 0.85
saveMapToJSONFileFunction · 0.85
indexOfStringFunction · 0.70

Tested by

no test coverage detected