File size: 9,496 Bytes
705812e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Duplicate Detection API Tester</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        h1 {
            color: #333;
            border-bottom: 3px solid #4CAF50;
            padding-bottom: 10px;
        }
        h2 {
            color: #555;
            margin-top: 0;
        }
        .endpoint {
            background: #f9f9f9;
            padding: 15px;
            border-left: 4px solid #4CAF50;
            margin: 15px 0;
            border-radius: 4px;
        }
        .url {
            background: #e8f5e9;
            padding: 10px;
            border-radius: 4px;
            font-family: monospace;
            word-break: break-all;
            margin: 10px 0;
        }
        a {
            color: #4CAF50;
            text-decoration: none;
            font-weight: bold;
        }
        a:hover {
            text-decoration: underline;
        }
        button {
            background: #4CAF50;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            margin: 5px;
        }
        button:hover {
            background: #45a049;
        }
        #result {
            background: #f5f5f5;
            padding: 15px;
            border-radius: 4px;
            margin-top: 15px;
            max-height: 500px;
            overflow-y: auto;
            font-family: monospace;
            font-size: 12px;
            white-space: pre-wrap;
        }
        .success {
            color: #4CAF50;
            font-weight: bold;
        }
        .error {
            color: #f44336;
            font-weight: bold;
        }
        .info {
            color: #2196F3;
        }
        .suggestion-item {
            background: white;
            padding: 10px;
            margin: 10px 0;
            border-radius: 4px;
            border-left: 3px solid #4CAF50;
        }
        .suggestion-item h4 {
            margin: 0 0 10px 0;
            color: #333;
        }
        .suggestion-item p {
            margin: 5px 0;
            color: #666;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>πŸ” Duplicate Detection API Tester</h1>
        <p class="info">Test the Duplicate Transaction Detection API directly from your browser</p>
    </div>

    <div class="container">
        <h2>1. Health Check Endpoint</h2>
        <div class="endpoint">
            <strong>Endpoint:</strong> GET /health
            <div class="url">
                <a href="https://LogicGoInfotechSpaces-duplicate-transaction-detection.hf.space/health" target="_blank">
                    https://LogicGoInfotechSpaces-duplicate-transaction-detection.hf.space/health
                </a>
            </div>
            <button onclick="testHealth()">Test Health Endpoint</button>
            <div id="healthResult"></div>
        </div>
    </div>

    <div class="container">
        <h2>2. Suggestions Endpoint</h2>
        <div class="endpoint">
            <strong>Endpoint:</strong> GET /suggestions
            <div class="url">
                <a href="https://LogicGoInfotechSpaces-duplicate-transaction-detection.hf.space/suggestions?limit=5" target="_blank">
                    https://LogicGoInfotechSpaces-duplicate-transaction-detection.hf.space/suggestions?limit=5
                </a>
            </div>
            <label>
                Limit: 
                <input type="number" id="limitInput" value="5" min="1" max="500" style="width: 60px; padding: 5px;">
            </label>
            <button onclick="testSuggestions()">Test Suggestions Endpoint</button>
            <div id="suggestionsResult"></div>
        </div>
    </div>

    <div class="container">
        <h2>3. Quick Links</h2>
        <div class="endpoint">
            <p><strong>Direct Browser Links:</strong></p>
            <ul>
                <li>
                    <a href="https://LogicGoInfotechSpaces-duplicate-transaction-detection.hf.space/health" target="_blank">
                        Health Check
                    </a>
                </li>
                <li>
                    <a href="https://LogicGoInfotechSpaces-duplicate-transaction-detection.hf.space/suggestions" target="_blank">
                        All Suggestions (default limit: 50)
                    </a>
                </li>
                <li>
                    <a href="https://LogicGoInfotechSpaces-duplicate-transaction-detection.hf.space/suggestions?limit=10" target="_blank">
                        10 Suggestions
                    </a>
                </li>
                <li>
                    <a href="https://LogicGoInfotechSpaces-duplicate-transaction-detection.hf.space/suggestions?limit=5" target="_blank">
                        5 Suggestions
                    </a>
                </li>
            </ul>
        </div>
    </div>

    <script>
        const BASE_URL = 'https://LogicGoInfotechSpaces-duplicate-transaction-detection.hf.space';

        async function testHealth() {
            const resultDiv = document.getElementById('healthResult');
            resultDiv.innerHTML = '<p class="info">Testing...</p>';
            
            try {
                const response = await fetch(`${BASE_URL}/health`);
                const data = await response.json();
                
                if (response.ok) {
                    resultDiv.innerHTML = `
                        <div class="success">βœ“ Health Check Successful!</div>
                        <div id="result">${JSON.stringify(data, null, 2)}</div>
                    `;
                } else {
                    resultDiv.innerHTML = `
                        <div class="error">βœ— Error: ${response.status}</div>
                        <div id="result">${JSON.stringify(data, null, 2)}</div>
                    `;
                }
            } catch (error) {
                resultDiv.innerHTML = `
                    <div class="error">βœ— Request Failed</div>
                    <div id="result">Error: ${error.message}</div>
                `;
            }
        }

        async function testSuggestions() {
            const resultDiv = document.getElementById('suggestionsResult');
            const limit = document.getElementById('limitInput').value;
            resultDiv.innerHTML = '<p class="info">Loading suggestions...</p>';
            
            try {
                const response = await fetch(`${BASE_URL}/suggestions?limit=${limit}`);
                const data = await response.json();
                
                if (response.ok) {
                    let html = `
                        <div class="success">βœ“ Success! Found ${data.length} suggestions</div>
                    `;
                    
                    if (data.length > 0) {
                        html += '<h3>Sample Suggestions:</h3>';
                        data.slice(0, 3).forEach((suggestion, index) => {
                            html += `
                                <div class="suggestion-item">
                                    <h4>Suggestion ${index + 1}</h4>
                                    <p><strong>ID:</strong> ${suggestion._id}</p>
                                    <p><strong>Candidates:</strong> ${suggestion.candidate_ids.length} transaction(s)</p>
                                    <p><strong>Amount Delta:</strong> ${suggestion.details.amount_delta_pct.toFixed(2)}%</p>
                                    <p><strong>Time Delta:</strong> ${suggestion.details.time_delta_minutes.toFixed(2)} minutes</p>
                                    <p><strong>Merchant Match:</strong> ${suggestion.details.merchant_match_rule}</p>
                                    <p><strong>Status:</strong> ${suggestion.status}</p>
                                    <p><strong>Generated:</strong> ${suggestion.audit.generated_at}</p>
                                </div>
                            `;
                        });
                        
                        html += `<div id="result" style="margin-top: 15px;">${JSON.stringify(data, null, 2)}</div>`;
                    } else {
                        html += '<p class="info">No suggestions found yet. The scheduler may need more time.</p>';
                    }
                    
                    resultDiv.innerHTML = html;
                } else {
                    resultDiv.innerHTML = `
                        <div class="error">βœ— Error: ${response.status}</div>
                        <div id="result">${JSON.stringify(data, null, 2)}</div>
                    `;
                }
            } catch (error) {
                resultDiv.innerHTML = `
                    <div class="error">βœ— Request Failed</div>
                    <div id="result">Error: ${error.message}</div>
                `;
            }
        }
    </script>
</body>
</html>