@rpcbase/server 0.353.0-uiimport.0 → 0.354.0-treefloatview.0
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/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
const assert = require("assert")
|
|
3
|
+
const debug = require("debug")
|
|
4
|
+
|
|
5
|
+
const Notification = require("../models/Notification")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const log = debug("notifications:ack")
|
|
9
|
+
|
|
10
|
+
const ack_notification = async(payload, ctx) => {
|
|
11
|
+
const {notification_id} = payload
|
|
12
|
+
assert(notification_id, "missing notification id")
|
|
13
|
+
|
|
14
|
+
const notif = await Notification.findOne({_id: notification_id}, {ack_at_ms: 1}, {ctx})
|
|
15
|
+
notif.ack_at_ms = payload.ack_at_ms
|
|
16
|
+
|
|
17
|
+
await notif.save({ctx})
|
|
18
|
+
|
|
19
|
+
log("acknowledged notification:", notification_id)
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
status: "ok",
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = ack_notification
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
// const Group = require("../models/Group")
|
|
3
|
+
|
|
4
|
+
const get_notifications = async(payload, ctx) => {
|
|
5
|
+
// const groups = await Group.find({
|
|
6
|
+
// // _owners: {$in: []}
|
|
7
|
+
// }, null, {ctx})
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
status: "ok",
|
|
11
|
+
notifications: [],
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = get_notifications
|
|
16
|
+
|
|
17
|
+
// const get_notifications = async () => {
|
|
18
|
+
// const uid = getUid()
|
|
19
|
+
// const db = firebase.firestore()
|
|
20
|
+
//
|
|
21
|
+
// const query = await db.collection("notifications").where("owner", "==", uid).get()
|
|
22
|
+
// const notifications = query.docs.map((doc) => {
|
|
23
|
+
// return doc.data()
|
|
24
|
+
// })
|
|
25
|
+
//
|
|
26
|
+
// // const forms = _.uniqBy(
|
|
27
|
+
// // _.flatten(
|
|
28
|
+
// // result.map((query) => {
|
|
29
|
+
// // return query.docs
|
|
30
|
+
// // }),
|
|
31
|
+
// // ).map((table) => {
|
|
32
|
+
// // const data = table.data()
|
|
33
|
+
// // data.id = table.id
|
|
34
|
+
// // return data
|
|
35
|
+
// // }),
|
|
36
|
+
// // "id",
|
|
37
|
+
// // )
|
|
38
|
+
// return notifications
|
|
39
|
+
// }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
## Long Lived Tasks (LLTs)
|
|
2
|
+
|
|
3
|
+
These are large jobs that typically take a while to run (minutes / hours).
|
|
4
|
+
|
|
5
|
+
The user and sometimes the system needs to be updated on progress of these tasks.
|
|
6
|
+
|
|
7
|
+
Any task that takes more than 10 seconds should be a long lived task.
|
|
8
|
+
https://www.nngroup.com/articles/response-times-3-important-limits/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
const assert = require("assert")
|
|
3
|
+
const Promise = require("bluebird")
|
|
4
|
+
|
|
5
|
+
const queue = require("@rpcbase/server/queue")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const get_llts = async(payload, ctx) => {
|
|
9
|
+
const {env_id} = payload
|
|
10
|
+
assert(env_id, "unable to find env_id")
|
|
11
|
+
|
|
12
|
+
const jobs = await queue.get_jobs(["active"])
|
|
13
|
+
// console.log("WOW GOT JOBS", jobs)
|
|
14
|
+
|
|
15
|
+
const target_jobs = jobs.filter((j) => j.id.toString().startsWith(`llt-${env_id}`))
|
|
16
|
+
|
|
17
|
+
const tasks = await Promise.map(
|
|
18
|
+
target_jobs,
|
|
19
|
+
async(j) => {
|
|
20
|
+
const logs = await j.queue.getJobLogs(j.id)
|
|
21
|
+
console.log("Llogs", logs)
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
id: j.id,
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{concurrency: 16},
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
tasks.length > 0 && console.log("tasks", tasks)
|
|
31
|
+
|
|
32
|
+
target_jobs.forEach((j) => {
|
|
33
|
+
console.log("LLT TARGET PROGRESS", j._progress)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
status: "ok",
|
|
38
|
+
llts: [],
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = get_llts
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
|
|
3
|
+
const WorkflowExecution = require("../models/workflows/WorkflowExecution")
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const set_seen = async(payload, ctx) => {
|
|
7
|
+
const {notif_type} = payload
|
|
8
|
+
|
|
9
|
+
if (notif_type === "workflow") {
|
|
10
|
+
const workflow_exec = await WorkflowExecution.findOne({_id: payload.exec_id}, {_id: 1}, {ctx})
|
|
11
|
+
workflow_exec.seen_at = payload.seen_at
|
|
12
|
+
|
|
13
|
+
await workflow_exec.save({ctx})
|
|
14
|
+
} else {
|
|
15
|
+
throw new Error("set_seen unknown notif_type")
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// console.log("Set notif seen", payload)
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
status: "ok",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = set_seen
|