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/project-status.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
/*
7
This table contains the current overall status about a running project.
8
This is the sister-table to "project-info".
9
In contrast, this table provides much less frequently changed pieces of status information.
10
For example, project version, certain "alerts", disk usage, etc.
11
Its intended usage is to subscribe to it once you open a project and notify the user if certain alerts go off.
12
*/
13
14
import { Table } from "./types";
15
16
Table({
17
name: "project_status",
18
fields: {
19
project_id: {
20
type: "uuid",
21
desc: "The project id.",
22
},
23
status: {
24
// change this according to all the usual schema rules
25
type: "map",
26
pg_type: "JSONB[]",
27
desc: "Status of this project",
28
},
29
},
30
rules: {
31
durability: "ephemeral", // won't be stored in the database at all ever.
32
desc:
33
"Project status, like version, certain 'alerts', disk usage, ...",
34
primary_key: ["project_id"], // can list multiple another field if you want to have multiple records for a project.
35
user_query: {
36
get: {
37
pg_where: ["projects"],
38
fields: {
39
project_id: null,
40
status: null,
41
},
42
},
43
set: {
44
// users can set that they are interested in this
45
fields: {
46
project_id: "project_id",
47
status: true,
48
},
49
},
50
},
51
52
project_query: {
53
get: {
54
pg_where: [{ "project_id = $::UUID": "project_id" }],
55
fields: {
56
project_id: null,
57
status: null,
58
},
59
},
60
set: {
61
// delete=true, since project *IS* allowed to delete entries
62
delete: true,
63
fields: {
64
project_id: "project_id",
65
status: true,
66
},
67
},
68
},
69
},
70
});
71
72