Skip to content

Commit 638f993

Browse files
committed
fix the dropdown to get companies from companies json instead of leetcode problems json, rm duplicate morgan stanley entry
1 parent 9abd484 commit 638f993

File tree

2 files changed

+12
-42
lines changed

2 files changed

+12
-42
lines changed

src/assets/data/problems_by_company.json

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28850,36 +28850,6 @@
2885028850
"freq_alltime": 0.0
2885128851
}
2885228852
],
28853-
"Morgan Stanley": [
28854-
{
28855-
"title": "Two Sum",
28856-
"id": 1
28857-
},
28858-
{
28859-
"title": "3Sum",
28860-
"id": 15
28861-
},
28862-
{
28863-
"title": "Longest Valid Parentheses",
28864-
"id": 32
28865-
},
28866-
{
28867-
"title": "Search in Rotated Sorted Array",
28868-
"id": 33
28869-
},
28870-
{
28871-
"title": "Merge Intervals",
28872-
"id": 56
28873-
},
28874-
{
28875-
"title": "LRU Cache",
28876-
"id": 146
28877-
},
28878-
{
28879-
"title": "Best Team With No Conflicts",
28880-
"id": 1748
28881-
}
28882-
],
2888328853
"IBM": [
2888428854
{
2888528855
"title": "Two Sum",

src/problems-by-company/company.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,28 @@ function addCompanyProblems(sortMethod: string) {
155155
async function addCompaniesToSelect() {
156156
const companySearch = document.getElementById('companySearch') as HTMLInputElement;
157157
const companyList = document.getElementById('companyList') as HTMLDataListElement;
158-
let uniqueCompanies = new Set<string>();
158+
let companies = [];
159159

160-
const data = await new Promise<{ leetcodeProblems: LeetcodeProblems }>(resolve => {
161-
chrome.storage.local.get('leetcodeProblems', function (items: { [key: string]: any; }) {
162-
resolve(items as { leetcodeProblems: LeetcodeProblems });
160+
const data = await new Promise<{ companyProblems: any }>((resolve) => {
161+
chrome.storage.local.get('companyProblems', function (data) {
162+
resolve(data);
163163
});
164164
});
165165

166-
data.leetcodeProblems.questions.forEach((question: Question) => {
167-
if (question.companies) {
168-
question.companies.forEach((company: Company) => {
169-
uniqueCompanies.add(company.name);
170-
});
166+
const companyProblems = data.companyProblems;
167+
// add all the keys to the set
168+
Object.keys(companyProblems).forEach((company) => {
169+
if (company) {
170+
console.log(company);
171+
companies.push(company);
171172
}
172173
});
173174

174175
// Event when the "Enter" key is pressed or an option is selected from the dropdown
175176
const handleSelection = () => {
176177
const inputValue = companySearch.value;
177178
// Find the selected company in a case-insensitive manner
178-
const selectedCompany = Array.from(uniqueCompanies).find(
179+
const selectedCompany = Array.from(companies).find(
179180
(company) => company.toLowerCase() === inputValue.toLowerCase()
180181
);
181182
if (selectedCompany) {
@@ -193,8 +194,7 @@ async function addCompaniesToSelect() {
193194

194195
companySearch.addEventListener('change', handleSelection);
195196

196-
// Convert the Set to an Array and sort it alphabetically
197-
const sortedCompanies = Array.from(uniqueCompanies).sort();
197+
const sortedCompanies = companies.sort();
198198

199199
sortedCompanies.forEach((company) => {
200200
const option = document.createElement('option');

0 commit comments

Comments
 (0)