(group string, model string, retry int)
| 88 | } |
| 89 | |
| 90 | func getChannelQuery(group string, model string, retry int) (*gorm.DB, error) { |
| 91 | maxPrioritySubQuery := DB.Model(&Ability{}).Select("MAX(priority)").Where(commonGroupCol+" = ? and model = ? and enabled = ?", group, model, true) |
| 92 | channelQuery := DB.Where(commonGroupCol+" = ? and model = ? and enabled = ? and priority = (?)", group, model, true, maxPrioritySubQuery) |
| 93 | if retry != 0 { |
| 94 | priority, err := getPriority(group, model, retry) |
| 95 | if err != nil { |
| 96 | return nil, err |
| 97 | } else { |
| 98 | channelQuery = DB.Where(commonGroupCol+" = ? and model = ? and enabled = ? and priority = ?", group, model, true, priority) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return channelQuery, nil |
| 103 | } |
| 104 | |
| 105 | // 修改GetRandomSatisfiedChannel函数,添加渠道标签过滤参数 |
| 106 | func GetRandomSatisfiedChannel(group string, model string, retry int, channelTag *string) (*Channel, error) { |
no test coverage detected