chore: fix twts
This commit is contained in:
		
							parent
							
								
									69755e14d2
								
							
						
					
					
						commit
						e58cd8e3f1
					
				
							
								
								
									
										10
									
								
								http.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								http.go
									
									
									
									
									
								
							@ -255,13 +255,14 @@ func httpServer(ctx context.Context, app *appState) error {
 | 
			
		||||
		if v, ok := strconv.Atoi(r.URL.Query().Get("limit")); ok == nil {
 | 
			
		||||
			limit = v
 | 
			
		||||
		}
 | 
			
		||||
		limit = min(100, max(1, limit))
 | 
			
		||||
 | 
			
		||||
		var offset int64 = 0
 | 
			
		||||
		if v, ok := strconv.ParseInt(r.URL.Query().Get("offset"), 10, 64); ok == nil {
 | 
			
		||||
			offset = v
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		twts, end, err := func(uri string, limit int, offset int64) ([]types.Twt, int64, error) {
 | 
			
		||||
		twts, offset, end, err := func(uri string, limit int, offset int64) ([]types.Twt, int64, int64, error) {
 | 
			
		||||
			args := make([]any, 0, 3)
 | 
			
		||||
			where := `where feed_id in (select feed_id from feeds where state != 'permanantly-dead')`
 | 
			
		||||
 | 
			
		||||
@ -280,7 +281,6 @@ func httpServer(ctx context.Context, app *appState) error {
 | 
			
		||||
				offset += end
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			limit = min(100, max(1, limit))
 | 
			
		||||
			offset = max(1, offset)
 | 
			
		||||
 | 
			
		||||
			args = append(args, limit, offset-int64(limit))
 | 
			
		||||
@ -320,7 +320,7 @@ func httpServer(ctx context.Context, app *appState) error {
 | 
			
		||||
			)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				span.RecordError(err)
 | 
			
		||||
				return nil, 0, err
 | 
			
		||||
				return nil, 0, 0, err
 | 
			
		||||
			}
 | 
			
		||||
			defer rows.Close()
 | 
			
		||||
 | 
			
		||||
@ -338,14 +338,14 @@ func httpServer(ctx context.Context, app *appState) error {
 | 
			
		||||
				err = rows.Scan(&o.FeedID, &o.Hash, &o.Conv, &o.Nick, &o.URI, &o.Text)
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					span.RecordError(err)
 | 
			
		||||
					return nil, 0, err
 | 
			
		||||
					return nil, 0, 0, err
 | 
			
		||||
				}
 | 
			
		||||
				twter := types.NewTwter(o.Nick, o.URI)
 | 
			
		||||
				twt, _ := lextwt.ParseLine(o.Text, &twter)
 | 
			
		||||
				twts = append(twts, twt)
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return twts, end, err
 | 
			
		||||
			return twts, offset, end, err
 | 
			
		||||
		} (uri, limit, offset)
 | 
			
		||||
		span.RecordError(err)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user