Skip to content

Commit

Permalink
lint and minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Adamski committed Jan 23, 2025
1 parent 8302875 commit d243a0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions bin/validate_live_pixel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ function main() {
}

function queryClickhouse(pixelDefs) {
var agents = "'" + productDef.agents.join("','") + "'";
let agents = "'" + productDef.agents.join("','") + "'";

Check failure on line 46 in bin/validate_live_pixel.mjs

View workflow job for this annotation

GitHub Actions / lint

'agents' is never reassigned. Use 'const' instead
const agentString = productDef.agents.length ? `AND agent IN (${agents})` : '';

const pixelQueryResults = {};
for(const pixel of Object.keys(pixelDefs)) {
console.log('Querying for', pixel)
const pixel_id = pixel.split(/[-\.]/)[0];
const queryString = `SELECT DISTINCT request FROM metrics.pixels WHERE pixel_id = '${pixel_id}' AND date > now() - INTERVAL 30 DAY AND pixel ILIKE '${pixel}%' ${agentString} LIMIT 1000`;
console.log('queryString', queryString)
const pixelID = pixel.split(/[-.]/)[0];
const queryString = `SELECT DISTINCT request FROM metrics.pixels WHERE pixel_id = '${pixelID}' AND date > now() - INTERVAL 30 DAY AND pixel ILIKE '${pixel}%' ${agentString} LIMIT 1000`;
const clickhouseQuery = spawnSync( 'clickhouse-client', [ '--host', clickhouseHost, '--query', queryString ] );
const resultString = clickhouseQuery.stdout.toString();
const resultErr = clickhouseQuery.stderr.toString();
Expand All @@ -66,16 +65,14 @@ function queryClickhouse(pixelDefs) {
}

function validateQueryForPixels(prefix, pixelQuery, paramsValidator) {
var minVersion = productDef.target;
let minVersion = productDef.target;

Check failure on line 68 in bin/validate_live_pixel.mjs

View workflow job for this annotation

GitHub Actions / lint

'minVersion' is never reassigned. Use 'const' instead

const lines = pixelQuery.split('\n');
console.log(`Received ${lines.length} results`)
for (let line of lines) {
if (line == '') continue;
if (line === '') continue;
line = getNormalizedCase(line);
const pixelRequest = line.split('/')[2];
const parts = pixelRequest.split('?');
const url = parts[1];
const pixelDef = pixelDefs[prefix];

logErrors(`ERROR for '${pixelRequest}\n`, paramsValidator.validateLivePixels(pixelDef, prefix, line, ignoreParams, minVersion));
Expand Down
2 changes: 1 addition & 1 deletion src/params_validator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class ParamsValidator {
const paramsStruct = Object.fromEntries(new URLSearchParams(livePixelRequestParams));
const versionKey = minVersion.key;
if (versionKey && paramsStruct[versionKey]) {
if (compareVersions(paramsStruct[versionKey], minVersion.version) == -1) {
if (compareVersions(paramsStruct[versionKey], minVersion.version) === -1) {
return []
}
}
Expand Down

0 comments on commit d243a0b

Please sign in to comment.