Simplify query calls
This commit is contained in:
		@@ -45,6 +45,15 @@ func ( this QueryResult ) Message() ( string, error ) {
 | 
			
		||||
    if this.Schedules == nil {
 | 
			
		||||
 | 
			
		||||
        q := *this.Query
 | 
			
		||||
 | 
			
		||||
        if len( *q.Results ) == 0 {
 | 
			
		||||
            terms := make( []string, len(*q.SearchTerms), len(*q.SearchTerms) )
 | 
			
		||||
            for i, term := range *q.SearchTerms {
 | 
			
		||||
                terms[i] = term.Org
 | 
			
		||||
            }
 | 
			
		||||
            return "", fmt.Errorf( "Not Found: \"%s\"", strings.Join( terms, "\", \"" ) )
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if q.Key == "" {
 | 
			
		||||
            sort.Sort( query.ByKey( *q.Results ) )
 | 
			
		||||
            for _, entry := range *q.Results {
 | 
			
		||||
@@ -53,7 +62,7 @@ func ( this QueryResult ) Message() ( string, error ) {
 | 
			
		||||
                sb.WriteString( " " )
 | 
			
		||||
                writeShortRoute( &this.Lang, &sb, busStop )
 | 
			
		||||
            }
 | 
			
		||||
        } else if 1 == len( *q.SearchTerms ) && 0 < len( *q.Results ) {
 | 
			
		||||
        } else if 1 == len( *q.SearchTerms ) {
 | 
			
		||||
 | 
			
		||||
            // Route listing
 | 
			
		||||
            st := map[string] *BusStop{}
 | 
			
		||||
@@ -101,12 +110,6 @@ func ( this QueryResult ) Message() ( string, error ) {
 | 
			
		||||
                sb.WriteString( "\n" )
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        } else if 1 < len( *q.SearchTerms ) && len( *q.Results ) == 0 {
 | 
			
		||||
            terms := make( []string, len(*q.SearchTerms), len(*q.SearchTerms) )
 | 
			
		||||
            for i, term := range *q.SearchTerms {
 | 
			
		||||
                terms[i] = term.Org
 | 
			
		||||
            }
 | 
			
		||||
            return "", fmt.Errorf( "Not Found: \"%s\"", strings.Join( terms, "\", \"" ) )
 | 
			
		||||
        } else {
 | 
			
		||||
            return "", fmt.Errorf( "%s", "Unreachable condition occured!?" )
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user