• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CBIIT / bento-c3dc-frontend / 25695561366

09 Feb 2026 03:26PM UTC coverage: 0.167%. First build
25695561366

push

github

web-flow
Merge pull request #490 from CBIIT/1.8.0

1.8.0 Release

6 of 3680 branches covered (0.16%)

Branch coverage included in aggregate %.

0 of 925 new or added lines in 39 files covered. (0.0%)

10 of 5876 relevant lines covered (0.17%)

0.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/pages/CohortAnalyzer/HistogramPanel/useKmplot.js
NEW
1
import { useEffect, useState, useRef } from 'react';
×
NEW
2
import { gql } from '@apollo/client';
×
3
import { useApolloClient } from '@apollo/client';
4

NEW
5
const KM_PLOT_QUERY = gql`
×
6
  query kMPlot(
7
    $c1: [String],
8
    $c2: [String],
9
    $c3: [String]
10
  ) {
11
    kMPlot(
12
      c1: $c1,
13
      c2: $c2,
14
      c3: $c3
15
    ) {
16
      id
17
      time
18
      event
19
      group
20
      __typename
21
    }
22
  }
23
`;
24

25
/**
26
 * Custom hook to fetch and manage KM plot data
27
 * @param {Array} c1 - Cohort 1 array
28
 * @param {Array} c2 - Cohort 2 array
29
 * @param {Array} c3 - Cohort 3 array
30
 * @returns {Object} { data, loading, error }
31
 */
32
export default function useKmplot({ c1, c2, c3 }) {
NEW
33
  const [data, setData] = useState([]);
×
NEW
34
  const [loading, setLoading] = useState(false);
×
NEW
35
  const [error, setError] = useState(null);
×
NEW
36
  const client = useApolloClient();
×
NEW
37
  const isMountedRef = useRef(true);
×
NEW
38
  const fetchInProgressRef = useRef(false);
×
39

NEW
40
  useEffect(() => {
×
NEW
41
    isMountedRef.current = true;
×
42
    
NEW
43
    return () => {
×
NEW
44
      isMountedRef.current = false;
×
45
    };
46
  }, []);
47

NEW
48
  useEffect(() => {
×
49
    // Don't fetch if no cohorts are selected
NEW
50
    const hasCohorts = (c1 && c1.length > 0) || (c2 && c2.length > 0) || (c3 && c3.length > 0);
×
51
    
NEW
52
    if (!hasCohorts) {
×
NEW
53
      setData([]);
×
NEW
54
      setLoading(false);
×
NEW
55
      setError(null);
×
NEW
56
      return;
×
57
    }
58
    
59
    // Prevent double fetch calls
NEW
60
    if (fetchInProgressRef.current) {
×
NEW
61
      return;
×
62
    }
63
    
NEW
64
    const fetchKmPlot = async () => {
×
NEW
65
      fetchInProgressRef.current = true;
×
NEW
66
      setLoading(true);
×
NEW
67
      setError(null);
×
68
      
NEW
69
      try {
×
NEW
70
        const result = await client.query({
×
71
          query: KM_PLOT_QUERY,
72
          variables: { c1, c2, c3 },
73
          fetchPolicy: 'no-cache', 
74
        });
75

76
        // Only update state if component is still mounted
NEW
77
        if (!isMountedRef.current) {
×
NEW
78
          return;
×
79
        }
80

NEW
81
        if (result.errors) {
×
NEW
82
          throw new Error((result.errors[0] && result.errors[0].message) || 'Unknown error');
×
83
        }
84

85
        // Use the fetched data from GraphQL
NEW
86
        setData((result.data && result.data.kMPlot) || []);
×
NEW
87
        setError(null);
×
88
      } catch (err) {
NEW
89
        console.error('Error fetching KM plot data:', err);
×
NEW
90
        if (isMountedRef.current) {
×
NEW
91
          setError(err);
×
NEW
92
          setData([]);
×
93
        }
94
      } finally {
NEW
95
        if (isMountedRef.current) {
×
NEW
96
          setLoading(false);
×
97
        }
NEW
98
        fetchInProgressRef.current = false;
×
99
      }
100
    };
101

NEW
102
    fetchKmPlot();
×
103
  }, [c1, c2, c3, client]);
104

NEW
105
  return { data, loading, error };
×
106
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc