Skip to content

Commit d320aa8

Browse files
authored
chore: deprecate rubygems-dependents-ingest workflow (#4339)
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent b14d417 commit d320aa8

10 files changed

Lines changed: 5 additions & 224 deletions

File tree

services/apps/packages_worker/src/activities.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ export {
3333
} from './pypi/activities'
3434
export { getCriticalPypiCount } from './pypi/downloads/getCriticalPypiCount'
3535
export { processNuGetBatch } from './nuget/activities'
36-
export {
37-
processRubyGemsCoreBatch,
38-
processRubyGemsCriticalBatch,
39-
processRubyGemsDependentsBatch,
40-
} from './rubygems/activities'
36+
export { processRubyGemsCoreBatch, processRubyGemsCriticalBatch } from './rubygems/activities'
4137
export {
4238
processSecurityContactsBatch,
4339
ingestSecurityContactsForPurlActivity,
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import {
2-
scheduleRubyGemsCriticalIngestion,
3-
scheduleRubyGemsDependentsIngestion,
4-
scheduleRubyGemsIngestion,
5-
} from '../rubygems/schedule'
1+
import { scheduleRubyGemsCriticalIngestion, scheduleRubyGemsIngestion } from '../rubygems/schedule'
62
import { svc } from '../service'
73

84
setImmediate(async () => {
95
await svc.init()
106
await scheduleRubyGemsIngestion()
117
await scheduleRubyGemsCriticalIngestion()
12-
await scheduleRubyGemsDependentsIngestion()
138
await svc.start()
149
})

services/apps/packages_worker/src/config.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,6 @@ export function getRubyGemsCriticalConfig() {
100100
}
101101
}
102102

103-
export function getRubyGemsDependentsConfig() {
104-
return {
105-
batchSize: parseInt(process.env.RUBYGEMS_DEPENDENTS_BATCH_SIZE ?? '10000', 10),
106-
concurrency: parseInt(process.env.RUBYGEMS_DEPENDENTS_CONCURRENCY ?? '50', 10),
107-
}
108-
}
109-
110103
export function getDockerhubConfig() {
111104
return {
112105
hubBaseUrl: requireEnv('DOCKERHUB_API_BASE_URL'),
Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
import { getServiceChildLogger } from '@crowd/logging'
22

3-
import {
4-
getRubyGemsConfig,
5-
getRubyGemsCriticalConfig,
6-
getRubyGemsDependentsConfig,
7-
} from '../config'
3+
import { getRubyGemsConfig, getRubyGemsCriticalConfig } from '../config'
84
import { getPackagesDb } from '../db'
95

106
import { processBatch as processCoreBatch } from './runRubyGemsCoreLoop'
117
import { processBatch as processCriticalBatch } from './runRubyGemsCriticalLoop'
12-
import {
13-
DependentsBatchResult,
14-
processBatch as processDependentsBatch,
15-
} from './runRubyGemsDependentsLoop'
168
import { BatchResult } from './types'
179

1810
const log = getServiceChildLogger('rubygems-activity')
@@ -35,13 +27,3 @@ export async function processRubyGemsCriticalBatch(
3527
log.info({ ...result }, 'RubyGems critical batch complete')
3628
return result
3729
}
38-
39-
export async function processRubyGemsDependentsBatch(
40-
afterId = '0',
41-
): Promise<DependentsBatchResult> {
42-
const config = getRubyGemsDependentsConfig()
43-
const qx = await getPackagesDb()
44-
const result = await processDependentsBatch(qx, config, afterId)
45-
log.info({ ...result }, 'RubyGems dependents batch complete')
46-
return result
47-
}

services/apps/packages_worker/src/rubygems/client.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,3 @@ export function fetchOwners(name: string): Promise<RubyGemsFetchResult<RubyGemsO
5252
`https://rubygems.org/api/v1/gems/${encodeURIComponent(name)}/owners.json`,
5353
)
5454
}
55-
56-
export function fetchReverseDependencies(name: string): Promise<RubyGemsFetchResult<string[]>> {
57-
return rubyGemsGet<string[]>(
58-
`https://rubygems.org/api/v1/gems/${encodeURIComponent(name)}/reverse_dependencies.json`,
59-
)
60-
}

services/apps/packages_worker/src/rubygems/runRubyGemsDependentsLoop.ts

Lines changed: 0 additions & 87 deletions
This file was deleted.

services/apps/packages_worker/src/rubygems/schedule.ts

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { ScheduleAlreadyRunning, ScheduleOverlapPolicy } from '@temporalio/client'
22

33
import { svc } from '../service'
4-
import {
5-
ingestRubyGemsCriticalDetails,
6-
ingestRubyGemsDependents,
7-
ingestRubyGemsPackages,
8-
} from '../workflows'
4+
import { ingestRubyGemsCriticalDetails, ingestRubyGemsPackages } from '../workflows'
95

106
export async function scheduleRubyGemsIngestion(): Promise<void> {
117
const { temporal } = svc
@@ -80,40 +76,3 @@ export async function scheduleRubyGemsCriticalIngestion(): Promise<void> {
8076
}
8177
}
8278
}
83-
84-
export async function scheduleRubyGemsDependentsIngestion(): Promise<void> {
85-
const { temporal } = svc
86-
if (!temporal) throw new Error('Temporal client not initialized')
87-
88-
try {
89-
await temporal.schedule.create({
90-
scheduleId: 'rubygems-dependents-ingest',
91-
spec: {
92-
cronExpressions: ['0 3 * * 0'],
93-
},
94-
policies: {
95-
overlap: ScheduleOverlapPolicy.SKIP,
96-
catchupWindow: '1 hour',
97-
},
98-
action: {
99-
type: 'startWorkflow',
100-
workflowType: ingestRubyGemsDependents,
101-
workflowId: 'rubygems-weekly-dependents',
102-
taskQueue: 'rubygems-worker',
103-
workflowRunTimeout: '24 hours',
104-
retry: {
105-
initialInterval: '30 seconds',
106-
backoffCoefficient: 2,
107-
maximumAttempts: 5,
108-
},
109-
args: [],
110-
},
111-
})
112-
} catch (err) {
113-
if (err instanceof ScheduleAlreadyRunning) {
114-
svc.log.info('Schedule rubygems-dependents-ingest already exists, skipping creation.')
115-
} else {
116-
throw err
117-
}
118-
}
119-
}

services/apps/packages_worker/src/rubygems/workflows.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,3 @@ export async function ingestRubyGemsCriticalDetails(afterId = '0'): Promise<void
2424
}
2525
await continueAsNew<typeof ingestRubyGemsCriticalDetails>(result.lastId)
2626
}
27-
28-
export async function ingestRubyGemsDependents(afterId = '0'): Promise<void> {
29-
const result = await acts.processRubyGemsDependentsBatch(afterId)
30-
if (result.lastId === null) {
31-
log.info('RubyGems dependents ingestion complete — no more work, exiting.', { ...result })
32-
return
33-
}
34-
await continueAsNew<typeof ingestRubyGemsDependents>(result.lastId)
35-
}

services/apps/packages_worker/src/workflows/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ export {
2525
ingestPypiDownloadsDaily,
2626
} from '../pypi/downloads/ingestPypiDownloads'
2727
export { ingestNuGetPackages } from '../nuget/workflows'
28-
export {
29-
ingestRubyGemsCriticalDetails,
30-
ingestRubyGemsDependents,
31-
ingestRubyGemsPackages,
32-
} from '../rubygems/workflows'
28+
export { ingestRubyGemsCriticalDetails, ingestRubyGemsPackages } from '../rubygems/workflows'
3329
export {
3430
ingestSecurityContacts,
3531
ingestSecurityContactsForPurlWorkflow,

services/libs/data-access-layer/src/osspckgs/rubygems.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -62,41 +62,3 @@ export async function listRubyGemsCriticalPackagesToSync(
6262
{ limit, afterId },
6363
)
6464
}
65-
66-
export type RubyGemsPackageForDependents = {
67-
id: string
68-
name: string
69-
}
70-
71-
export async function listRubyGemsPackagesForDependents(
72-
qx: QueryExecutor,
73-
options: { limit: number; afterId?: string },
74-
): Promise<RubyGemsPackageForDependents[]> {
75-
const { limit, afterId = '0' } = options
76-
return qx.select(
77-
`
78-
SELECT p.id, p.name
79-
FROM packages p
80-
WHERE p.ecosystem = 'rubygems'
81-
AND p.id > $(afterId)::bigint
82-
ORDER BY p.id ASC
83-
LIMIT $(limit)
84-
`,
85-
{ limit, afterId },
86-
)
87-
}
88-
89-
export async function updateRubyGemsDependentCount(
90-
qx: QueryExecutor,
91-
packageId: string,
92-
dependentCount: number,
93-
): Promise<void> {
94-
await qx.result(
95-
`UPDATE packages
96-
SET dependent_count = $(dependentCount),
97-
last_synced_at = NOW()
98-
WHERE id = $(packageId)::bigint
99-
AND dependent_count IS DISTINCT FROM $(dependentCount)`,
100-
{ packageId, dependentCount },
101-
)
102-
}

0 commit comments

Comments
 (0)