mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 19:58:09 +00:00
uberf-8294: do not upgrade stale workspaces (#6748)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
3c63f108b2
commit
b585a9a721
@ -1017,7 +1017,8 @@ export async function listWorkspacesByAccount (db: Db, email: string): Promise<W
|
||||
export async function countWorkspacesInRegion (
|
||||
db: Db,
|
||||
region: string = '',
|
||||
upToVersion?: Data<Version>
|
||||
upToVersion?: Data<Version>,
|
||||
visitedSince?: number
|
||||
): Promise<number> {
|
||||
const regionQuery = region === '' ? { $or: [{ region: { $exists: false } }, { region: '' }] } : { region }
|
||||
const query: Filter<Workspace>['$and'] = [
|
||||
@ -1039,6 +1040,10 @@ export async function countWorkspacesInRegion (
|
||||
})
|
||||
}
|
||||
|
||||
if (visitedSince !== undefined) {
|
||||
query.push({ lastVisit: { $gt: visitedSince } })
|
||||
}
|
||||
|
||||
return await db.collection<Workspace>(WORKSPACE_COLLECTION).countDocuments({
|
||||
$and: query
|
||||
})
|
||||
@ -1256,7 +1261,7 @@ export async function workerHandshake (
|
||||
const workspacesCnt = await ctx.with(
|
||||
'count-workspaces-in-region',
|
||||
{},
|
||||
async (ctx) => await countWorkspacesInRegion(db, region, version)
|
||||
async (ctx) => await countWorkspacesInRegion(db, region, version, Date.now() - 24 * 60 * 60 * 1000)
|
||||
)
|
||||
|
||||
await db.collection<UpgradeStatistic>(UPGRADE_COLLECTION).insertOne({
|
||||
@ -1494,7 +1499,10 @@ export async function getPendingWorkspace (
|
||||
{
|
||||
$or: [{ mode: 'active' }, { mode: { $exists: false } }]
|
||||
},
|
||||
versionQuery
|
||||
versionQuery,
|
||||
{
|
||||
lastVisit: { $gt: Date.now() - 24 * 60 * 60 * 1000 }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user