MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / Views

Function Views

src/environmentd/src/http/static/js/memory.jsx:110–241  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

108}
109
110function Views(props) {
111 const [currentDataflow, setCurrentDataflow] = useState(null);
112 const [includeSystemCatalog, setIncludeSystemCatalog] = useState(false);
113 const [records, setRecords] = useState(null);
114 const [loading, setLoading] = useState(true);
115 const [error, setError] = useState(false);
116
117 useEffect(() => {
118 const search = new URLSearchParams(location.search);
119 const dataflow = search.get('dataflow');
120 if (dataflow) {
121 setCurrentDataflow(dataflow);
122 }
123 setIncludeSystemCatalog(search.get('system_catalog') === 'true');
124 }, []);
125
126 useEffect(() => {
127 setCurrentDataflow(null);
128 }, [props]);
129
130 useEffect(() => {
131 const params = new URLSearchParams(location.search);
132 if (currentDataflow) {
133 params.set('dataflow', currentDataflow);
134 } else {
135 params.delete('dataflow');
136 }
137 window.history.replaceState({}, '', `${location.pathname}?${params}`);
138 }, [currentDataflow]);
139
140 const whereFragment = includeSystemCatalog ? `` : `WHERE name NOT LIKE 'Dataflow: mz_catalog.%'`;
141
142 useEffect(() => {
143 setLoading(true);
144 setError(false);
145
146 const load = async () => {
147 const {
148 results: [_set_cluster, _set_replica, records_table],
149 } = await query(`
150 SET cluster = ${formatNameForQuery(props.clusterName)};
151 SET cluster_replica = ${formatNameForQuery(props.replicaName)};
152 SELECT
153 id, name, batches, records, size, capacity, allocations
154 FROM
155 mz_introspection.mz_records_per_dataflow
156 ${whereFragment}
157 ORDER BY
158 records DESC
159 `);
160
161 setRecords(records_table.rows);
162 setLoading(false);
163 };
164 load().catch((error) => {
165 setError(error);
166 setLoading(false);
167 });

Callers

nothing calls this directly

Calls 5

loadFunction · 0.70
getMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected