@canonry/canonry 7.83.0 → 7.83.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ import {
10
10
  backfillSnapshotAttributionCommand,
11
11
  backfillTrafficClassificationCommand,
12
12
  replayQueryAuditLog
13
- } from "./chunk-33EHXZDH.js";
13
+ } from "./chunk-3GXAL3F7.js";
14
14
  import "./chunk-OMNS42ZQ.js";
15
15
  import "./chunk-WA4FD5Y6.js";
16
16
  import "./chunk-HGMYEDAQ.js";
@@ -18,8 +18,8 @@ import "./chunk-LZGVQSZL.js";
18
18
  import {
19
19
  backfillProjectAnswerMentions,
20
20
  backfillProjectAnswerMentionsInChunks
21
- } from "./chunk-OIHR2BDK.js";
22
- import "./chunk-FICCBAAY.js";
21
+ } from "./chunk-5AGYH5PX.js";
22
+ import "./chunk-IQTMHY23.js";
23
23
  import "./chunk-WDEDEEWA.js";
24
24
  import "./chunk-3UFQI4KL.js";
25
25
  import "./chunk-PHVIMUAQ.js";
@@ -24,11 +24,11 @@ import {
24
24
  createRunCompetitorResolver,
25
25
  readMarketCompetitorNames,
26
26
  refreshSnapshotMentionIdentity
27
- } from "./chunk-OIHR2BDK.js";
27
+ } from "./chunk-5AGYH5PX.js";
28
28
  import {
29
29
  classifyAiUserFetch,
30
30
  classifyCrawler
31
- } from "./chunk-FICCBAAY.js";
31
+ } from "./chunk-IQTMHY23.js";
32
32
  import {
33
33
  RawEventSampleEventTypes,
34
34
  aiUserFetchEventsHourly,
@@ -439,7 +439,7 @@ No DB writes performed. Re-run without --dry-run to apply.`);
439
439
  }
440
440
  }
441
441
  async function backfillInsightsCommand(project, opts) {
442
- const { IntelligenceService } = await import("./intelligence-service-4D34S2P6.js");
442
+ const { IntelligenceService } = await import("./intelligence-service-AMXDCTS2.js");
443
443
  const config = loadConfig();
444
444
  const db = createClient(config.database);
445
445
  migrate(db);
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-HGMYEDAQ.js";
11
11
  import {
12
12
  buildOpenApiDocument
13
- } from "./chunk-OIHR2BDK.js";
13
+ } from "./chunk-5AGYH5PX.js";
14
14
  import {
15
15
  DEFAULT_COMPETITOR_AUTO_ALIAS_MODE,
16
16
  MeasurementPortfolioLists,
@@ -10,7 +10,7 @@ import {
10
10
  normalizeCloudflareWorkerEvent,
11
11
  sessionizeJourneyRequests,
12
12
  verifyRequestSignature
13
- } from "./chunk-FICCBAAY.js";
13
+ } from "./chunk-IQTMHY23.js";
14
14
  import {
15
15
  currentOutcomeAttribution,
16
16
  getRequestContext,
@@ -49501,9 +49501,10 @@ async function googleRoutes(app, opts) {
49501
49501
  });
49502
49502
  const conditions = [eq70(gbpReviews.projectId, project.id)];
49503
49503
  if (locationName) conditions.push(eq70(gbpReviews.locationName, locationName));
49504
- if (negativeOnly) conditions.push(sql24`${gbpReviews.starRating} BETWEEN 1 AND ${negativeMaxStars}`);
49505
- const total = app.db.select({ n: sql24`count(*)` }).from(gbpReviews).where(and58(...conditions)).get()?.n ?? 0;
49506
- const reviews = app.db.select().from(gbpReviews).where(and58(...conditions)).orderBy(desc31(gbpReviews.updateTime), gbpReviews.reviewName).limit(limit).all().map((r) => ({
49504
+ const scoped = app.db.select().from(gbpReviews).where(and58(...conditions)).orderBy(desc31(gbpReviews.updateTime), gbpReviews.reviewName).all();
49505
+ const listed = withoutRepeatedPlacesReviews(app.db, project.id, scoped).filter((r) => !negativeOnly || isNegativeReviewRating(r.starRating, negativeMaxStars));
49506
+ const total = listed.length;
49507
+ const reviews = listed.slice(0, limit).map((r) => ({
49507
49508
  locationName: r.locationName,
49508
49509
  origin: r.origin,
49509
49510
  reviewName: r.reviewName,
@@ -49579,6 +49580,26 @@ function parseReviewNegativeFlag(value) {
49579
49580
  if (value === "true" || value === "1") return true;
49580
49581
  throw validationError('"negative" must be "true" or "false"');
49581
49582
  }
49583
+ function withoutRepeatedPlacesReviews(db, projectId, rows) {
49584
+ if (!rows.some((r) => r.origin === "places")) return rows;
49585
+ const v4Locations = new Set(db.select({ locationName: gbpReviewRatings.locationName }).from(gbpReviewRatings).where(and58(eq70(gbpReviewRatings.projectId, projectId), eq70(gbpReviewRatings.origin, "gbp"))).all().map((row) => row.locationName));
49586
+ const covered = new Set(db.select({ locationName: gbpLocations.locationName, reviewsAccess: gbpLocations.reviewsAccess }).from(gbpLocations).where(eq70(gbpLocations.projectId, projectId)).all().filter((loc) => businessProfileReviewsCover(loc.reviewsAccess ?? null, v4Locations.has(loc.locationName))).map((loc) => loc.locationName));
49587
+ const v4Copies = new Set(db.select({ locationName: gbpReviews.locationName, reviewerName: gbpReviews.reviewerName, createTime: gbpReviews.createTime }).from(gbpReviews).where(and58(eq70(gbpReviews.projectId, projectId), eq70(gbpReviews.origin, "gbp"))).all().map(reviewIdentity).filter((key) => key !== null));
49588
+ return rows.filter((r) => {
49589
+ if (r.origin !== "places") return true;
49590
+ if (covered.has(r.locationName)) return false;
49591
+ const identity = reviewIdentity(r);
49592
+ return identity === null || !v4Copies.has(identity);
49593
+ });
49594
+ }
49595
+ function reviewIdentity(review) {
49596
+ const reviewer = review.reviewerName?.trim().toLowerCase();
49597
+ const created = review.createTime === null ? Number.NaN : Date.parse(review.createTime);
49598
+ if (!reviewer || !Number.isFinite(created)) return null;
49599
+ return `${review.locationName}
49600
+ ${reviewer}
49601
+ ${Math.floor(created / 1e3)}`;
49602
+ }
49582
49603
  function parseReviewLimit(value) {
49583
49604
  if (value === void 0 || value === "") return REVIEW_LIST_DEFAULT_LIMIT;
49584
49605
  const parsed = Number(value);
@@ -47,7 +47,7 @@ function queueServeHandoff() {
47
47
  async function runPendingServeHandoff(format) {
48
48
  if (!pendingServeHandoff) return;
49
49
  pendingServeHandoff = false;
50
- const { serveCommand } = await import("./serve-HWLAUXAU.js");
50
+ const { serveCommand } = await import("./serve-KGZW5WPA.js");
51
51
  await serveCommand(format);
52
52
  }
53
53