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