mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 22:42:24 -05:00 
			
		
		
		
	boobs
This commit is contained in:
		
					parent
					
						
							
								1725769733
							
						
					
				
			
			
				commit
				
					
						9c544e732c
					
				
			
		
					 1 changed files with 23 additions and 3 deletions
				
			
		|  | @ -106,7 +106,7 @@ func init() { | |||
| 				Where("? IS NULL", bun.Ident("in_reply_to_id")). | ||||
| 				Where("? < ?", bun.Ident("id"), maxID). | ||||
| 				OrderExpr("? DESC", bun.Ident("id")). | ||||
| 				Limit(500). | ||||
| 				Limit(100). | ||||
| 				Scan(ctx); err != nil && !errors.Is(err, sql.ErrNoRows) { | ||||
| 				return gtserror.Newf("error selecting top-level statuses: %w", err) | ||||
| 			} | ||||
|  | @ -173,6 +173,19 @@ func init() { | |||
| 			return err | ||||
| 		} | ||||
| 
 | ||||
| 		// Reset max ID. | ||||
| 		maxID = id.Highest | ||||
| 
 | ||||
| 		// Create a temporary index on thread_id_new for stragglers. | ||||
| 		log.Info(ctx, "creating temporary statuses thread_id_new index") | ||||
| 		if _, err := db.NewCreateIndex(). | ||||
| 			Table("statuses"). | ||||
| 			Index("statuses_thread_id_new_idx"). | ||||
| 			Column("thread_id_new"). | ||||
| 			Exec(ctx); err != nil { | ||||
| 			return gtserror.Newf("error creating new thread_id index: %w", err) | ||||
| 		} | ||||
| 
 | ||||
| 		// Open a new transaction lads. | ||||
| 		tx, err = db.BeginTx(ctx, nil) | ||||
| 		if err != nil { | ||||
|  | @ -192,8 +205,8 @@ func init() { | |||
| 			if err := tx.NewSelect(). | ||||
| 				Model(&statuses). | ||||
| 				Column("id"). | ||||
| 				Where("? IS NULL", bun.Ident("thread_id")). | ||||
| 				Limit(250). | ||||
| 				Where("? = ?", bun.Ident("thread_id_new"), id.Lowest). | ||||
| 				Limit(500). | ||||
| 				Scan(ctx); err != nil && !errors.Is(err, sql.ErrNoRows) { | ||||
| 				return gtserror.Newf("error selecting unthreaded statuses: %w", err) | ||||
| 			} | ||||
|  | @ -253,6 +266,13 @@ func init() { | |||
| 			) | ||||
| 		} | ||||
| 
 | ||||
| 		log.Info(ctx, "dropping temporary thread_id_new index") | ||||
| 		if _, err := db.NewDropIndex(). | ||||
| 			Index("statuses_thread_id_new_idx"). | ||||
| 			Exec(ctx); err != nil { | ||||
| 			return gtserror.Newf("error dropping temporary thread_id_new index: %w", err) | ||||
| 		} | ||||
| 
 | ||||
| 		log.Info(ctx, "dropping old thread_to_statuses table") | ||||
| 		if _, err := db.NewDropTable(). | ||||
| 			Table("thread_to_statuses"). | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue