proca 1.7.3 → 1.7.4
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/README.md +30 -20
- package/package.json +1 -1
- package/src/commands/action/list.mjs +1 -1
- package/src/commands/action/replay.mjs +2 -0
- package/src/commands/action/requeue.mjs +116 -20
package/README.md
CHANGED
|
@@ -209,24 +209,24 @@ EXAMPLES
|
|
|
209
209
|
```
|
|
210
210
|
USAGE
|
|
211
211
|
$ proca action list [TITLE] -o <organisation name> [--json | --human | --csv] [--env
|
|
212
|
-
<value>] [-c <campaign
|
|
212
|
+
<value>] [-c <campaign name>] [--limit <value>] [--today | --after 2025-04-09] [--optin] [--testing] [--doi] [--utm
|
|
213
213
|
| --simplify] [--comment | ]
|
|
214
214
|
|
|
215
215
|
ARGUMENTS
|
|
216
216
|
TITLE name of the campaign, % for wildchar
|
|
217
217
|
|
|
218
218
|
FLAGS
|
|
219
|
-
-c, --campaign=<campaign
|
|
220
|
-
-o, --org=<organisation name>
|
|
221
|
-
--after=2025-04-09
|
|
222
|
-
--[no-]comment
|
|
223
|
-
--doi
|
|
224
|
-
--env=<value>
|
|
225
|
-
--limit=<value>
|
|
226
|
-
--optin
|
|
227
|
-
--testing
|
|
228
|
-
--today
|
|
229
|
-
--[no-]utm
|
|
219
|
+
-c, --campaign=<campaign name> name of the campaign, % for wildchar
|
|
220
|
+
-o, --org=<organisation name> (required) campaigns of the organisation (coordinator or partner)
|
|
221
|
+
--after=2025-04-09 only actions after a date
|
|
222
|
+
--[no-]comment display the comment
|
|
223
|
+
--doi only export the double optin actions
|
|
224
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
225
|
+
--limit=<value> max number of actions
|
|
226
|
+
--optin only export the optin actions
|
|
227
|
+
--testing also export the test actions
|
|
228
|
+
--today only actions today
|
|
229
|
+
--[no-]utm display the utm tracking parameters
|
|
230
230
|
|
|
231
231
|
OUTPUT FLAGS
|
|
232
232
|
--csv Format output as csv
|
|
@@ -262,18 +262,28 @@ EXAMPLES
|
|
|
262
262
|
|
|
263
263
|
## `proca action requeue`
|
|
264
264
|
|
|
265
|
-
requeue
|
|
265
|
+
requeue actions
|
|
266
266
|
|
|
267
267
|
```
|
|
268
268
|
USAGE
|
|
269
|
-
$ proca action requeue
|
|
270
|
-
|
|
269
|
+
$ proca action requeue -o <org name> -q
|
|
270
|
+
CUSTOM_ACTION_CONFIRM|CUSTOM_ACTION_DELIVER|CUSTOM_SUPPORTER_CONFIRM|EMAIL_SUPPORTER|SQS|WEBHOOK [--json | --human |
|
|
271
|
+
--csv] [--env <value>] [--simplify] [-c <campaign name>] [--limit <value>] [--today | --after 2025-04-09] [--optin]
|
|
272
|
+
[--testing] [--doi]
|
|
271
273
|
|
|
272
274
|
FLAGS
|
|
273
|
-
-
|
|
274
|
-
-
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
-c, --campaign=<campaign name> name of the campaign, % for wildchar
|
|
276
|
+
-o, --org=<org name> (required) name of the org
|
|
277
|
+
-q, --queue=<option> (required) [default: CUSTOM_ACTION_DELIVER] queue to redeliver to
|
|
278
|
+
<options: CUSTOM_ACTION_CONFIRM|CUSTOM_ACTION_DELIVER|CUSTOM_SUPPORTER_CONFIRM|EMAIL_S
|
|
279
|
+
UPPORTER|SQS|WEBHOOK>
|
|
280
|
+
--after=2025-04-09 only actions after a date
|
|
281
|
+
--doi only export the double optin actions
|
|
282
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
283
|
+
--limit=<value> [default: 1000] how many actions per page
|
|
284
|
+
--optin only export the optin actions
|
|
285
|
+
--testing also export the test actions
|
|
286
|
+
--today only actions today
|
|
277
287
|
|
|
278
288
|
OUTPUT FLAGS
|
|
279
289
|
--csv Format output as csv
|
|
@@ -282,7 +292,7 @@ OUTPUT FLAGS
|
|
|
282
292
|
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
283
293
|
|
|
284
294
|
DESCRIPTION
|
|
285
|
-
requeue
|
|
295
|
+
requeue actions
|
|
286
296
|
|
|
287
297
|
EXAMPLES
|
|
288
298
|
$ proca action requeue
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@ export default class List extends Command {
|
|
|
30
30
|
campaign: Flags.string({
|
|
31
31
|
char: "c",
|
|
32
32
|
description: "name of the campaign, % for wildchar",
|
|
33
|
-
helpValue: "<campaign
|
|
33
|
+
helpValue: "<campaign name>",
|
|
34
34
|
}),
|
|
35
35
|
limit: Flags.string({
|
|
36
36
|
description: "max number of actions",
|
|
@@ -1,50 +1,147 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
3
|
import Command from "#src/procaCommand.mjs";
|
|
4
|
-
import { gql, mutation } from "#src/urql.mjs";
|
|
4
|
+
import { gql, mutation, query } from "#src/urql.mjs";
|
|
5
5
|
|
|
6
6
|
export default class ActionRequeue extends Command {
|
|
7
|
-
static description = "requeue
|
|
7
|
+
static description = "requeue actions";
|
|
8
8
|
|
|
9
9
|
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
10
10
|
|
|
11
11
|
static flags = {
|
|
12
12
|
...super.globalFlags,
|
|
13
|
-
id: Flags.string({
|
|
14
|
-
description: "action id",
|
|
15
|
-
parse: (input) => Number.parseInt(input, 10),
|
|
16
|
-
required: true,
|
|
17
|
-
}),
|
|
18
13
|
org: Flags.string({
|
|
19
14
|
char: "o",
|
|
20
15
|
required: true,
|
|
21
16
|
description: "name of the org",
|
|
22
17
|
helpValue: "<org name>",
|
|
23
18
|
}),
|
|
19
|
+
campaign: Flags.string({
|
|
20
|
+
char: "c",
|
|
21
|
+
description: "name of the campaign, % for wildchar",
|
|
22
|
+
helpValue: "<campaign name>",
|
|
23
|
+
}),
|
|
24
24
|
queue: Flags.string({
|
|
25
25
|
char: "q",
|
|
26
26
|
required: true,
|
|
27
27
|
description: "queue to redeliver to",
|
|
28
|
-
|
|
28
|
+
default: "CUSTOM_ACTION_DELIVER",
|
|
29
|
+
options: [
|
|
30
|
+
"CUSTOM_ACTION_CONFIRM",
|
|
31
|
+
"CUSTOM_ACTION_DELIVER",
|
|
32
|
+
"CUSTOM_SUPPORTER_CONFIRM",
|
|
33
|
+
"EMAIL_SUPPORTER",
|
|
34
|
+
"SQS",
|
|
35
|
+
"WEBHOOK",
|
|
36
|
+
],
|
|
37
|
+
}),
|
|
38
|
+
limit: Flags.string({
|
|
39
|
+
description: "how many actions per page",
|
|
40
|
+
default: 1000,
|
|
41
|
+
parse: (input) => Number.parseInt(input, 10),
|
|
42
|
+
}),
|
|
43
|
+
after: Flags.string({
|
|
44
|
+
description: "only actions after a date",
|
|
45
|
+
helpValue: "2025-04-09",
|
|
46
|
+
parse: (input) => new Date(input).toISOString(),
|
|
47
|
+
}),
|
|
48
|
+
today: Flags.boolean({
|
|
49
|
+
description: "only actions today",
|
|
50
|
+
exclusive: ["after"],
|
|
51
|
+
parse: (input) => `${new Date().toISOString().split("T")[0]}T00:00:00Z`,
|
|
52
|
+
}),
|
|
53
|
+
optin: Flags.boolean({
|
|
54
|
+
description: "only export the optin actions",
|
|
55
|
+
default: false,
|
|
56
|
+
}),
|
|
57
|
+
testing: Flags.boolean({
|
|
58
|
+
description: "also export the test actions",
|
|
59
|
+
default: false,
|
|
29
60
|
}),
|
|
61
|
+
doi: Flags.boolean({
|
|
62
|
+
description: "only export the double optin actions",
|
|
63
|
+
default: false,
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
process = async (flags) => {
|
|
68
|
+
let page = 0;
|
|
69
|
+
let actions = 0;
|
|
70
|
+
let requeued = 0;
|
|
71
|
+
let error = 0;
|
|
72
|
+
while (true) {
|
|
73
|
+
const ids = await this.fetch(flags);
|
|
74
|
+
if (ids.length === 0) break;
|
|
75
|
+
const result = await this.requeue(flags.org, flags.queue, ids);
|
|
76
|
+
requeued += result.count;
|
|
77
|
+
error += result.failed;
|
|
78
|
+
flags.start = ids[ids.length - 1] + 1;
|
|
79
|
+
process.stdout.write(`\rrequeued ${requeued}, id> ${flags.start}`);
|
|
80
|
+
page += 1;
|
|
81
|
+
actions += ids.length;
|
|
82
|
+
}
|
|
83
|
+
process.stdout.write("\r\x1b[K");
|
|
84
|
+
return { pages: page, actions, requeued, error };
|
|
30
85
|
};
|
|
31
86
|
|
|
32
|
-
|
|
87
|
+
fetch = async (flags) => {
|
|
33
88
|
const Document = gql`
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
89
|
+
query (
|
|
90
|
+
$after: DateTime
|
|
91
|
+
$campaignId: Int
|
|
92
|
+
$campaignName: String
|
|
93
|
+
$includeTesting: Boolean
|
|
94
|
+
$limit: Int
|
|
95
|
+
$onlyDoubleOptIn: Boolean
|
|
96
|
+
$onlyOptIn: Boolean
|
|
97
|
+
$orgName: String!
|
|
98
|
+
$start: Int
|
|
99
|
+
) {
|
|
100
|
+
actions (
|
|
101
|
+
after: $after
|
|
102
|
+
campaignId: $campaignId
|
|
103
|
+
campaignName: $campaignName
|
|
104
|
+
includeTesting: $includeTesting
|
|
105
|
+
limit: $limit
|
|
106
|
+
onlyDoubleOptIn: $onlyDoubleOptIn
|
|
107
|
+
onlyOptIn: $onlyOptIn
|
|
108
|
+
orgName: $orgName
|
|
109
|
+
start: $start
|
|
110
|
+
) {
|
|
111
|
+
actionId
|
|
112
|
+
}
|
|
113
|
+
}
|
|
40
114
|
`;
|
|
115
|
+
const result = await query(Document, {
|
|
116
|
+
after: flags.after,
|
|
117
|
+
campaignName: flags.campaign,
|
|
118
|
+
includeTesting: flags.testing,
|
|
119
|
+
limit: flags.limit,
|
|
120
|
+
onlyDoubleOptIn: flags.doi,
|
|
121
|
+
onlyOptIn: flags.optin,
|
|
122
|
+
orgName: flags.org,
|
|
123
|
+
start: flags.start,
|
|
124
|
+
});
|
|
125
|
+
const ids = [];
|
|
126
|
+
result.actions.forEach((d) => ids.push(d.actionId));
|
|
127
|
+
return ids;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
requeue = async (org, queue, ids) => {
|
|
131
|
+
const Document = gql`
|
|
132
|
+
mutation ($ids: [Int!], $org: String!, $queue: Queue!) {
|
|
133
|
+
requeueActions(ids: $ids, orgName: $org, queue: $queue) {
|
|
134
|
+
count
|
|
135
|
+
failed
|
|
136
|
+
}
|
|
137
|
+
}`;
|
|
41
138
|
const result = await mutation(Document, {
|
|
42
139
|
org,
|
|
43
|
-
|
|
44
|
-
|
|
140
|
+
queue,
|
|
141
|
+
ids,
|
|
45
142
|
});
|
|
46
143
|
//return result.users.map (d => {d.config = JSON.parse(d.config); return d});
|
|
47
|
-
return result.
|
|
144
|
+
return result.requeueActions;
|
|
48
145
|
};
|
|
49
146
|
|
|
50
147
|
table = (r) => {
|
|
@@ -52,9 +149,8 @@ mutation ($user: String!, $role: String!, $org: String!, message: String) {
|
|
|
52
149
|
};
|
|
53
150
|
|
|
54
151
|
async run() {
|
|
55
|
-
throw new Error("NOT IMPLEMENTED");
|
|
56
152
|
const { args, flags } = await this.parse();
|
|
57
|
-
const data = await this.
|
|
153
|
+
const data = await this.process(flags);
|
|
58
154
|
this.output(data);
|
|
59
155
|
}
|
|
60
156
|
}
|