-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(seer): Seer Autofix Settings Overview page #110758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
b48552c
feat(seer): Seer SCM Overview
ryan953 6a77ba3
review comment
ryan953 c6c4a94
Merge branch 'master' into ryan953/seer-scm-overview
ryan953 42d1203
iterate on loading state
ryan953 353911c
split component to make stories better
ryan953 8d0c066
squash
ryan953 0b7c980
split it up[
ryan953 06df154
Iterate!
ryan953 5d35c75
Iterate some more
ryan953 70f8adb
add autofix section stories
ryan953 ceff1b5
rm unused helpers
ryan953 d0034ef
tweak styles
ryan953 b9592a6
show Connect Projects and Repos button
ryan953 605aa60
Merge branch 'master' into ryan953/seer-overview
ryan953 38eecc4
Merge branch 'master' into ryan953/seer-overview
ryan953 45b0e63
iterate
ryan953 133b65d
iterate - w/ fancy radios
ryan953 1f98574
fix create pr counts
ryan953 6fd63ff
Merge branch 'master' into ryan953/seer-overview
ryan953 defedcb
fix test
ryan953 d840e5f
add bulk-edit of ser agent name
ryan953 743781b
add bulk-edit of seer create-pr field
ryan953 d6a7389
add busy state to the bulk edit buttons
ryan953 bb791b3
catch 429s and throw an error to the user. This happens because we ar…
ryan953 54fa762
rm connectedrepo and stopping point forms for now
ryan953 0785ab7
do chunking to avoid 429s a bit more
ryan953 0aa772b
disable buttons while requests are in-flight
ryan953 d5b4714
add tests for processInChunks
ryan953 f393df4
rm defaultAutomatedRunStoppingPoint field for now
ryan953 657bb6c
rm extra changes
ryan953 0d1fe15
fix issue while loading: shouldnt fallback to comparing to seer
ryan953 6b9ff53
handle case when were loading agent options
ryan953 c1c2cc1
mv organizationIntegrationsQueryOptions
ryan953 08249dd
Merge branch 'master' into ryan953/seer-overview
ryan953 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import {processInChunks} from 'sentry/utils/array/procesInChunks'; | ||
|
|
||
| describe('processInChunks', () => { | ||
| it('returns an empty array for empty input', async () => { | ||
| const fn = jest.fn().mockResolvedValue('x'); | ||
| const results = await processInChunks({items: [], chunkSize: 3, fn}); | ||
| expect(results).toEqual([]); | ||
| expect(fn).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('processes all items when count is less than chunkSize', async () => { | ||
| const fn = jest.fn((x: number) => Promise.resolve(x * 2)); | ||
| const results = await processInChunks({items: [1, 2], chunkSize: 5, fn}); | ||
| expect(results).toEqual([ | ||
| {status: 'fulfilled', value: 2}, | ||
| {status: 'fulfilled', value: 4}, | ||
| ]); | ||
| }); | ||
|
|
||
| it('processes all items when count equals chunkSize exactly', async () => { | ||
| const fn = jest.fn((x: number) => Promise.resolve(x * 2)); | ||
| const results = await processInChunks({items: [1, 2, 3], chunkSize: 3, fn}); | ||
| expect(results).toHaveLength(3); | ||
| expect(results.every(r => r.status === 'fulfilled')).toBe(true); | ||
| }); | ||
|
|
||
| it('processes all items across multiple chunks', async () => { | ||
| const fn = jest.fn((x: number) => Promise.resolve(x)); | ||
| const results = await processInChunks({ | ||
| items: [1, 2, 3, 4, 5], | ||
| chunkSize: 2, | ||
| fn, | ||
| }); | ||
| expect(results).toHaveLength(5); | ||
| expect(fn).toHaveBeenCalledTimes(5); | ||
| expect(results.map(r => (r.status === 'fulfilled' ? r.value : null))).toEqual([ | ||
| 1, 2, 3, 4, 5, | ||
| ]); | ||
| }); | ||
|
|
||
| it('preserves result order matching input order', async () => { | ||
| // Simulate varying async latency: later items resolve faster | ||
| const fn = jest.fn( | ||
| (x: number) => | ||
| new Promise<number>(resolve => setTimeout(() => resolve(x), (10 - x) * 10)) | ||
| ); | ||
| const results = await processInChunks({items: [1, 2, 3, 4, 5], chunkSize: 5, fn}); | ||
| expect(results.map(r => (r.status === 'fulfilled' ? r.value : null))).toEqual([ | ||
| 1, 2, 3, 4, 5, | ||
| ]); | ||
| }); | ||
|
|
||
| it('processes chunks sequentially, not all at once', async () => { | ||
| const callOrder: number[] = []; | ||
| const fn = jest.fn((x: number) => { | ||
| callOrder.push(x); | ||
| return Promise.resolve(x); | ||
| }); | ||
|
|
||
| await processInChunks({items: [1, 2, 3, 4, 5, 6], chunkSize: 2, fn}); | ||
|
|
||
| // Each chunk of 2 must start only after the previous chunk completes. | ||
| // Because fn is synchronous here, within each chunk the call order is | ||
| // preserved and chunks are processed sequentially. | ||
| expect(callOrder).toEqual([1, 2, 3, 4, 5, 6]); | ||
| }); | ||
|
|
||
| it('marks rejected items as rejected without stopping other items', async () => { | ||
| const fn = jest.fn((x: number) => | ||
| x === 3 ? Promise.reject(new Error('boom')) : Promise.resolve(x) | ||
| ); | ||
| const results = await processInChunks({items: [1, 2, 3, 4, 5], chunkSize: 5, fn}); | ||
| expect(results).toHaveLength(5); | ||
| expect(results[0]).toEqual({status: 'fulfilled', value: 1}); | ||
| expect(results[1]).toEqual({status: 'fulfilled', value: 2}); | ||
| expect(results[2]).toMatchObject({status: 'rejected', reason: expect.any(Error)}); | ||
| expect(results[3]).toEqual({status: 'fulfilled', value: 4}); | ||
| expect(results[4]).toEqual({status: 'fulfilled', value: 5}); | ||
| }); | ||
|
|
||
| it('continues processing later chunks when an earlier chunk has failures', async () => { | ||
| const fn = jest.fn((x: number) => | ||
| x === 1 ? Promise.reject(new Error('first chunk error')) : Promise.resolve(x) | ||
| ); | ||
| // chunk 1: [1] (fails), chunk 2: [2, 3] (succeeds) | ||
| const results = await processInChunks({items: [1, 2, 3], chunkSize: 1, fn}); | ||
| expect(results).toHaveLength(3); | ||
| expect(results[0]).toMatchObject({status: 'rejected'}); | ||
| expect(results[1]).toEqual({status: 'fulfilled', value: 2}); | ||
| expect(results[2]).toEqual({status: 'fulfilled', value: 3}); | ||
| }); | ||
|
|
||
| it('handles chunkSize of 1 by processing items one at a time', async () => { | ||
| const fn = jest.fn((x: number) => Promise.resolve(x)); | ||
| const results = await processInChunks({items: [10, 20, 30], chunkSize: 1, fn}); | ||
| expect(results).toHaveLength(3); | ||
| expect(results.map(r => (r.status === 'fulfilled' ? r.value : null))).toEqual([ | ||
| 10, 20, 30, | ||
| ]); | ||
| }); | ||
|
|
||
| it('handles chunkSize larger than item count', async () => { | ||
| const fn = jest.fn((x: number) => Promise.resolve(x)); | ||
| const results = await processInChunks({items: [1, 2], chunkSize: 100, fn}); | ||
| expect(results).toHaveLength(2); | ||
| expect(fn).toHaveBeenCalledTimes(2); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| interface Props<Item, Result> { | ||
| chunkSize: number; | ||
| fn: (item: Item) => Promise<Result>; | ||
| items: Item[]; | ||
| } | ||
|
|
||
| export async function processInChunks<Item, Result>({ | ||
| items, | ||
| chunkSize, | ||
| fn, | ||
| }: Props<Item, Result>): Promise<Array<PromiseSettledResult<Result>>> { | ||
| const results: Array<PromiseSettledResult<Result>> = []; | ||
| for (let i = 0; i < items.length; i += chunkSize) { | ||
| const chunk = items.slice(i, i + chunkSize); | ||
| const chunkResults = await Promise.allSettled(chunk.map(fn)); | ||
| results.push(...chunkResults); | ||
| } | ||
| return results; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zero chunk size causes endless loop
Low Severity
processInChunksdoes not validatechunkSize. WithchunkSize <= 0,for (let i = 0; i < items.length; i += chunkSize)never advances correctly, so the function can loop forever and hang the caller.