MCPcopy Index your code
hub / github.com/apache/answer / parseViews

Method parseViews

internal/service/search_parser/search_parser.go:251–266  ·  view source on GitHub ↗

parseViews check search has views or not

(query *string)

Source from the content-addressed store, hash-verified

249
250// parseViews check search has views or not
251func (sp *SearchParser) parseViews(query *string) (views int) {
252 var (
253 q = *query
254 expr = `views:(\d+)`
255 )
256 views = -1
257
258 re := regexp.MustCompile(expr)
259 res := re.FindStringSubmatch(q)
260 if len(res) > 1 {
261 views = converter.StringToInt(res[1])
262 q = re.ReplaceAllString(q, "")
263 }
264 *query = strings.TrimSpace(q)
265 return
266}
267
268// parseAnswers check whether specified answer count for question
269func (sp *SearchParser) parseAnswers(query *string) (answers int) {

Callers 1

ParseStructureMethod · 0.95

Calls 1

StringToIntFunction · 0.92

Tested by

no test coverage detected