Skip to content

Commit 909b8bf

Browse files
feat: costPerRequest + nicer result link
1 parent 8441b32 commit 909b8bf

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

starter/src/constants.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,21 @@ export const ACTOR_CHEERIO_CHECKER_NAME = 'lukaskrivka/website-checker-cheerio';
33
export const ACTOR_PUPPETEER_CHECKER_NAME = 'lukaskrivka/website-checker-puppeteer';
44

55
export const ACTOR_PLAYWRIGHT_CHECKER_NAME = 'lukaskrivka/website-checker-playwright';
6+
7+
export const DEFAULT_COSTS = {
8+
COMPUTE_UNIT: 0.25,
9+
RESIDENTIAL_GB: 12.5,
10+
}
11+
12+
export const TABLE_FIELDS_ORDER = [
13+
'url',
14+
'checkerType',
15+
'proxyUsed',
16+
'totalPages',
17+
'success',
18+
'successRate',
19+
'estimatedCostPerRequest',
20+
'computeUnitsPerRequest',
21+
'residentialGBsPerRequest',
22+
'runUrl'
23+
]

starter/src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { convertInputToActorConfigs } from './configs.js';
66
import { waitForRunToFinishAndPushData, startRun } from './startRunAndPool.js';
77

88
import type { ActorInputData, FrontendActorState, PreparedActorConfig } from './typedefs.js';
9+
import { TABLE_FIELDS_ORDER } from './constants.js';
910

1011
const env = Actor.getEnv();
1112

@@ -86,6 +87,6 @@ Actor.main(async () => {
8687
await Actor.setValue('STATE', state);
8788

8889
log.info(`\nChecking ${state.totalUrls} URLs completed!`);
89-
log.info(`Please go to https://api.apify.com/v2/datasets/${env.defaultDatasetId}/items?clean=true&format=html to see the results`);
90-
log.info(`Go to https://api.apify.com/v2/datasets/${env.defaultDatasetId}/items?clean=true&format=json for the JSON output`);
90+
log.info(`NICER TABLE VIEW:\nhttps://api.apify.com/v2/datasets/${Actor.getEnv().defaultDatasetId}/items?clean=true&format=html`
91+
+ `&fields=${TABLE_FIELDS_ORDER.join(',')}`);
9192
});

starter/src/startRunAndPool.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Actor, ActorRun } from 'apify';
22

3+
import { DEFAULT_COSTS } from './constants.js';
34
import type { PreparedActorConfig, ActorCheckSimplifiedOutput, FixedActorRun } from './typedefs.js';
45

56
export async function startRun(run: PreparedActorConfig) {
@@ -28,6 +29,8 @@ export async function waitForRunToFinishAndPushData(runConfig: PreparedActorConf
2829
value.residentialGBs = Number(residentialGBs.toFixed(8));
2930
value.residentialGBsPerRequest = Number((residentialGBs / value.totalPages).toFixed(8));
3031
value.proxyUsed = runConfig.proxyUsed;
32+
value.estimatedCost = Number((computeUnits * DEFAULT_COSTS.COMPUTE_UNIT + residentialGBs * DEFAULT_COSTS.RESIDENTIAL_GB).toFixed(6));
33+
value.estimatedCostPerRequest = Number((value.estimatedCost / value.totalPages).toFixed(6));
3134

3235
if (runConfig.input['playwright.chrome']) {
3336
value.playwrightBrowser = 'chrome';

0 commit comments

Comments
 (0)