Skip to content

[usage] Batch list workspace instances in range#10789

Merged
roboquat merged 1 commit into
mainfrom
mp/usage-batch-wsi
Jun 21, 2022
Merged

[usage] Batch list workspace instances in range#10789
roboquat merged 1 commit into
mainfrom
mp/usage-batch-wsi

Conversation

@easyCZ
Copy link
Copy Markdown
Member

@easyCZ easyCZ commented Jun 21, 2022

Description

Lists Workspace Instances in batches of 100

Related Issue(s)

Fixes #

How to test

Unit tests

Release Notes

NONE

Documentation

NONE

@easyCZ easyCZ requested a review from a team June 21, 2022 08:15
@github-actions github-actions Bot added the team: webapp Issue belongs to the WebApp team label Jun 21, 2022
@easyCZ easyCZ force-pushed the mp/usage-batch-wsi branch 2 times, most recently from fb3558b to 0a73a23 Compare June 21, 2022 08:30
Where("creationTime < ?", TimeToISO8601(to)).
Where("startedTime != ?", "").
Find(&instances)
FindInBatches(&instancesInBatch, 1000, func(tx *gorm.DB, batch int) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the batch parameter intended to be used for? If it's not used can we replace it with _ ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


}

tx := conn.CreateInBatches(&instances, 1000)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to CreateInBatches here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't strictly, but felt like I should start a pattern of not doing things with more than 1k entries outside batches

@easyCZ easyCZ force-pushed the mp/usage-batch-wsi branch from 0a73a23 to febbad0 Compare June 21, 2022 09:05
@csweichel
Copy link
Copy Markdown
Contributor

csweichel commented Jun 21, 2022

/werft run

👍 started the job as gitpod-build-mp-usage-batch-wsi.4
(with .werft/ from main)

}

workspaceID := generateWorkspaceID()
workspaceID := GenerateWorkspaceID()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also fixes broken master due to a semantic merge.

@roboquat roboquat merged commit 3b0942d into main Jun 21, 2022
@roboquat roboquat deleted the mp/usage-batch-wsi branch June 21, 2022 10:09
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/M team: webapp Issue belongs to the WebApp team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants