CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/db-schema/mentions.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Table } from "./types";
7
8
Table({
9
name: "mentions",
10
fields: {
11
time: {
12
type: "timestamp",
13
desc: "when this mention happened.",
14
},
15
project_id: {
16
type: "uuid",
17
},
18
path: {
19
type: "string",
20
},
21
source: {
22
type: "uuid",
23
desc: "User who did the mentioning.",
24
},
25
target: {
26
type: "string",
27
desc: "uuid of user who was mentioned; later will have other possibilities including group names, 'all', etc.",
28
},
29
description: {
30
type: "string",
31
desc: "Extra text to describe the mention. eg. could be the containing message",
32
},
33
fragment_id: {
34
type: "string",
35
desc: "Text represenation of fragment_id, which is an indicator of exactly where the mention occurs in the document, e.g., a specific chat or cell in a notebook or line in a file.",
36
},
37
priority: {
38
type: "number",
39
desc: "optional integer priority. 0 = default, but could be 1 = higher priority, etc.",
40
},
41
error: {
42
type: "string",
43
desc: "some sort of error occured handling this mention",
44
},
45
action: {
46
type: "string",
47
desc: "what action was attempted by the backend - 'email', 'ignore'",
48
},
49
users: {
50
type: "map",
51
desc: "{account_id1: {read: boolean, saved: boolean}, account_id2: {...}}",
52
},
53
expire: {
54
type: "timestamp",
55
desc: "delete this row after this date, if not null",
56
},
57
},
58
rules: {
59
primary_key: ["time", "project_id", "path", "target"],
60
db_standby: "unsafe",
61
pg_indexes: ["action"],
62
user_query: {
63
get: {
64
pg_where: ["time >= NOW() - interval '45 days'", "projects"],
65
pg_changefeed: "projects",
66
options: [{ order_by: "-time" }, { limit: 500 }],
67
throttle_changes: 2000,
68
fields: {
69
time: null,
70
project_id: null,
71
path: null,
72
source: null,
73
target: null,
74
priority: null,
75
description: null,
76
fragment_id: null,
77
users: null,
78
},
79
},
80
set: {
81
fields: {
82
time({ time }) {
83
return time || new Date();
84
},
85
project_id: "project_write",
86
path: true,
87
source: true,
88
target: true,
89
priority: true,
90
description: true,
91
fragment_id: true,
92
users: true,
93
},
94
required_fields: {
95
project_id: true,
96
source: true,
97
path: true,
98
target: true,
99
},
100
},
101
},
102
},
103
});
104
105