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/news.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2023 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { ID } from "./crm";
7
import { Table } from "./types";
8
9
Table({
10
name: "news",
11
fields: {
12
id: ID,
13
date: {
14
type: "timestamp",
15
desc: "date of this news item",
16
},
17
title: {
18
type: "string",
19
desc: "short title of this news item",
20
},
21
text: {
22
type: "string",
23
desc: "markdown text of this news item",
24
},
25
tags: {
26
type: "array",
27
pg_type: "TEXT[]",
28
desc: "list of strings, e.g. ['jupyter', 'python']",
29
},
30
url: {
31
type: "string",
32
desc: "optional url",
33
},
34
channel: {
35
type: "string",
36
desc: 'e.g. "announcement", "feature", …', // defined in @cocalc/util/types/news → CHANNELS
37
},
38
hide: {
39
type: "boolean",
40
desc: "optionally, hide/retract this news item",
41
},
42
history: {
43
type: "map",
44
desc: "history of changes to this news item",
45
},
46
},
47
rules: {
48
primary_key: "id",
49
pg_indexes: ["date"],
50
anonymous: true, // allow users read access, even if not signed in
51
user_query: {
52
get: {
53
pg_where: [
54
"date >= NOW() - INTERVAL '3 months'",
55
"date <= NOW() + INTERVAL '1 minute'",
56
"channel != 'event'",
57
"hide IS NOT true",
58
],
59
pg_changefeed: "news",
60
options: [{ order_by: "-date" }, { limit: 100 }],
61
throttle_changes: 60 * 1000,
62
fields: {
63
// we only send title, and a link to open the news item
64
id: null,
65
date: null,
66
title: null,
67
tags: null,
68
channel: null,
69
hide: null,
70
},
71
},
72
// no set, all done via v2 API
73
},
74
},
75
});
76
77