Skip to content

Commit 15b3e76

Browse files
committed
add threads
1 parent 4c33c13 commit 15b3e76

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

backend/topic_processor.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import duckdb
44
import json
55
from collections import Counter
6+
from concurrent.futures import ThreadPoolExecutor
7+
from functools import partial
68

79
app = Flask(__name__)
810
# Configure CORS to allow all origins and methods
@@ -23,8 +25,9 @@ def process_topics():
2325
else: # GET request
2426
search_term = request.args.get('searchTerm', '').lower()
2527

26-
# Step 1: Load JSON into a DuckDB temp table
28+
# Step 1: Load JSON into a DuckDB temp table with parallel processing enabled
2729
con = duckdb.connect(database=':memory:')
30+
con.execute("SET threads TO 16;") # Adjust number based on your CPU cores
2831
con.execute("""
2932
CREATE TEMP TABLE repo AS
3033
SELECT * FROM read_json_auto('../public/data/repo_metadata.json');
@@ -49,11 +52,11 @@ def extract_names(item_ls):
4952
all_topics = [topic for topics in filtered_df["topics"] for topic in topics]
5053
topic_counts = Counter(all_topics)
5154

52-
# Optional: Remove the searched topic itself
55+
# Remove the searched topic itself
5356
topic_counts.pop(search_term, None)
5457

55-
# Step 6: Convert to list of dicts and sort
56-
topics = [{"name": name, "count": count} for name, count in topic_counts.items()]
58+
# Step 6: Convert to list of dicts and sort, only including topics with count > 1
59+
topics = [{"name": name, "count": count} for name, count in topic_counts.items() if count > 2]
5760
topics = sorted(topics, key=lambda x: x["count"], reverse=True)
5861

5962
return jsonify({

src/components/HistogramBars.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,18 @@ export const HistogramBars: FC<HistogramBarsProps> = ({ data, range, highlighted
103103
}, [data, range, highlightedTopic]);
104104

105105
return (
106-
<div style={{ width: '100%', height: '400px', padding: '10px' }}>
107-
<svg ref={svgRef} style={{ width: '100%', height: '100%' }}></svg>
106+
<div style={{
107+
width: '100%',
108+
height: '400px',
109+
padding: '10px',
110+
overflowX: 'hidden', // Hide horizontal scrollbar
111+
overflowY: 'auto' // Enable vertical scrolling when needed
112+
}}>
113+
<svg ref={svgRef} style={{
114+
width: '100%',
115+
minHeight: '100%', // Change height to minHeight
116+
height: 'auto' // Allow SVG to grow based on content
117+
}}></svg>
108118
</div>
109119
);
110120
};

0 commit comments

Comments
 (0)