@gscdump/analysis 5.6.0 → 5.7.1

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.
@@ -80,7 +80,7 @@ function buildDataQueryPlan(params, options) {
80
80
  const tableKey = options.adapter.inferTable(state.dimensions);
81
81
  if (prev) {
82
82
  const totals = buildTotalsSql(state, options);
83
- const comparison = resolveComparisonSQL(state, prev, options, params.comparisonFilter);
83
+ const comparison = resolveComparisonSQL(state, prev, options, params.comparisonFilter, params.comparisonOrderBy);
84
84
  extraQueries.unshift({
85
85
  name: "totals",
86
86
  sql: totals.sql,
@@ -192,8 +192,11 @@ function shapeDataQueryRowResults(rowMap, params) {
192
192
  clicksChange: -Number(p.clicks ?? 0)
193
193
  })) merged.push(row);
194
194
  }
195
- if (state.orderBy) {
196
- const { column, dir } = state.orderBy;
195
+ const changeOrder = params.comparisonOrderBy;
196
+ if (changeOrder) for (const row of merged) row.clicksChange = Number(row.clicks ?? 0) - Number(row.prevClicks ?? 0);
197
+ const order = changeOrder ?? state.orderBy;
198
+ if (order) {
199
+ const { column, dir } = order;
197
200
  merged.sort((a, b) => {
198
201
  const av = Number(a[column]) || 0;
199
202
  const bv = Number(b[column]) || 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/analysis",
3
3
  "type": "module",
4
- "version": "5.6.0",
4
+ "version": "5.7.1",
5
5
  "description": "GSC analyzers — striking-distance, opportunity, movers, decay, brand, clustering, concentration, seasonality. Pure row-based + DuckDB-native.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -61,9 +61,9 @@
61
61
  "node": ">=22.13.0"
62
62
  },
63
63
  "dependencies": {
64
- "@gscdump/engine": "^5.6.0",
65
- "@gscdump/engine-gsc-api": "^5.6.0",
66
- "gscdump": "^5.6.0",
64
+ "@gscdump/engine": "^5.7.1",
65
+ "@gscdump/engine-gsc-api": "^5.7.1",
66
+ "gscdump": "^5.7.1",
67
67
  "pluralize": "^8.0.0"
68
68
  },
69
69
  "devDependencies": {