@cccsaurora/howler-ui 2.15.0-dev.308 → 2.15.0-dev.310

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,26 +3,32 @@ import { Skeleton } from '@mui/material';
3
3
  import api from '@cccsaurora/howler-ui/api';
4
4
  import 'chartjs-adapter-dayjs-4';
5
5
  import useMyChart from '@cccsaurora/howler-ui/components/hooks/useMyChart';
6
- import { forwardRef, useEffect, useState } from 'react';
6
+ import { forwardRef, useEffect, useRef, useState } from 'react';
7
7
  import { Line } from 'react-chartjs-2';
8
8
  import { stringToColor } from '@cccsaurora/howler-ui/utils/utils';
9
9
  const Created = forwardRef(({ analytic }, ref) => {
10
10
  const { line } = useMyChart();
11
11
  const [loading, setLoading] = useState(false);
12
12
  const [ingestionData, setIngestionData] = useState({});
13
+ const queryRef = useRef();
13
14
  useEffect(() => {
14
15
  if (!analytic) {
15
16
  return;
16
17
  }
17
18
  setLoading(true);
18
- api.search.histogram.hit
19
- .post('timestamp', {
20
- query: `howler.analytic:("${analytic.name}")`,
21
- start: 'now-3M',
22
- gap: '1d',
23
- mincount: 0
19
+ if (!queryRef.current) {
20
+ queryRef.current = api.search.histogram.hit.post('timestamp', {
21
+ query: `howler.analytic:("${analytic.name}")`,
22
+ start: 'now-3M',
23
+ gap: '1d',
24
+ mincount: 0
25
+ });
26
+ }
27
+ queryRef.current
28
+ .then(result => {
29
+ setIngestionData(result);
30
+ queryRef.current = null;
24
31
  })
25
- .then(setIngestionData)
26
32
  .finally(() => setLoading(false));
27
33
  }, [analytic]);
28
34
  return analytic && !loading ? (_jsx(Line, { ref: ref, options: line('route.analytics.ingestion.title'), data: {
@@ -11,6 +11,9 @@ const Stacked = forwardRef(({ analytic, field, color }, ref) => {
11
11
  const [loading, setLoading] = useState(false);
12
12
  const [datasets, setDatasets] = useState([]);
13
13
  const fetchData = useCallback(async () => {
14
+ if (loading) {
15
+ return;
16
+ }
14
17
  try {
15
18
  setLoading(true);
16
19
  const result = await api.search.facet.hit.post({
@@ -44,6 +47,7 @@ const Stacked = forwardRef(({ analytic, field, color }, ref) => {
44
47
  finally {
45
48
  setLoading(false);
46
49
  }
50
+ // eslint-disable-next-line react-hooks/exhaustive-deps
47
51
  }, [analytic?.name, color, field]);
48
52
  useEffect(() => {
49
53
  if (!analytic) {
@@ -29,7 +29,8 @@ const ViewCard = ({ viewId, limit }) => {
29
29
  const timeout = setTimeout(() => setLoading(true), 200);
30
30
  dispatchApi(api.search.hit.post({
31
31
  query: view.query,
32
- rows: limit
32
+ rows: limit,
33
+ metadata: ['analytic']
33
34
  }))
34
35
  .then(res => setHits(res.items ?? []))
35
36
  .finally(() => {
package/package.json CHANGED
@@ -96,7 +96,7 @@
96
96
  "internal-slot": "1.0.7"
97
97
  },
98
98
  "type": "module",
99
- "version": "2.15.0-dev.308",
99
+ "version": "2.15.0-dev.310",
100
100
  "exports": {
101
101
  "./i18n": "./i18n.js",
102
102
  "./index.css": "./index.css",