@socialgouv/matomo-postgres 2.2.0-alpha.2 → 2.2.0-alpha.3
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.
package/dist/index.js
CHANGED
|
@@ -35,10 +35,6 @@ function run(date) {
|
|
|
35
35
|
referenceDate = new Date(date);
|
|
36
36
|
console.log(`✅ Using provided date parameter: ${referenceDate.toISOString()}`);
|
|
37
37
|
}
|
|
38
|
-
if (!referenceDate && process.env.STARTDATE) {
|
|
39
|
-
referenceDate = new Date(process.env.STARTDATE);
|
|
40
|
-
console.log(`✅ Using STARTDATE environment variable: ${referenceDate.toISOString()}`);
|
|
41
|
-
}
|
|
42
38
|
if (!referenceDate) {
|
|
43
39
|
console.log(`🔍 Looking for last event in database...`);
|
|
44
40
|
referenceDate = yield findLastEventInMatomo(db);
|
|
@@ -49,6 +45,10 @@ function run(date) {
|
|
|
49
45
|
console.log(`ℹ️ No previous events found in database`);
|
|
50
46
|
}
|
|
51
47
|
}
|
|
48
|
+
if (!referenceDate && process.env.STARTDATE) {
|
|
49
|
+
referenceDate = new Date(process.env.STARTDATE);
|
|
50
|
+
console.log(`✅ Using STARTDATE environment variable: ${referenceDate.toISOString()}`);
|
|
51
|
+
}
|
|
52
52
|
if (!referenceDate) {
|
|
53
53
|
referenceDate = new Date(new Date().getTime() - +INITIAL_OFFSET * 24 * 60 * 60 * 1000);
|
|
54
54
|
console.log(`✅ Using default offset (${INITIAL_OFFSET} days ago): ${referenceDate.toISOString()}`);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { sql } from 'kysely';
|
|
11
|
+
const PARTITIONED_MATOMO_TABLE_NAME = process.env.PARTITIONED_MATOMO_TABLE_NAME || 'matomo_partitioned';
|
|
12
|
+
export function up(db) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
// Create conditional index for convention collective analysis
|
|
15
|
+
yield sql `
|
|
16
|
+
CREATE INDEX IF NOT EXISTS idx_convention_analysis_matomo_partitioned
|
|
17
|
+
ON ${sql.id(PARTITIONED_MATOMO_TABLE_NAME)} (action_type, action_url, action_timestamp)
|
|
18
|
+
WHERE action_url LIKE 'https://code.travail.gouv.fr/convention-collective/%'
|
|
19
|
+
`.execute(db);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function down(db) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
// Drop the conditional index
|
|
25
|
+
yield sql `
|
|
26
|
+
DROP INDEX IF EXISTS idx_convention_analysis_matomo_partitioned
|
|
27
|
+
`.execute(db);
|
|
28
|
+
});
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socialgouv/matomo-postgres",
|
|
3
3
|
"description": "Extract visitor events from Matomo API and push to Postgres",
|
|
4
|
-
"version": "2.2.0-alpha.
|
|
4
|
+
"version": "2.2.0-alpha.3",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/index.js",
|