forked from farhoodlabs/paperclip
fix(skills): use acceptedSkills instead of listFull; cross-source slug check
- Replace redundant listFull() call with acceptedSkills to avoid extra DB round-trip - Check slug conflicts against full acceptedSkills list instead of just same-source skills - Call upsertAcceptedSkill after persisting to keep in-memory list current Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2017,7 +2017,7 @@ export function companySkillService(db: Db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-scan GitHub/sks_sh sources to pick up newly added skills
|
// Re-scan GitHub/sks_sh sources to pick up newly added skills
|
||||||
const existingSkills = await listFull(companyId);
|
const existingSkills = acceptedSkills;
|
||||||
const sourceByLocator = new Map<string, CompanySkill[]>();
|
const sourceByLocator = new Map<string, CompanySkill[]>();
|
||||||
for (const skill of existingSkills) {
|
for (const skill of existingSkills) {
|
||||||
if (skill.sourceType !== "github" && skill.sourceType !== "skills_sh") continue;
|
if (skill.sourceType !== "github" && skill.sourceType !== "skills_sh") continue;
|
||||||
@@ -2030,12 +2030,15 @@ export function companySkillService(db: Db) {
|
|||||||
try {
|
try {
|
||||||
const result = await readUrlSkillImports(companyId, sourceLocator, null);
|
const result = await readUrlSkillImports(companyId, sourceLocator, null);
|
||||||
for (const nextSkill of result.skills) {
|
for (const nextSkill of result.skills) {
|
||||||
const existing = skillsAtSource.find((s) => s.slug === nextSkill.slug);
|
const existing = acceptedSkills.find((s) => s.slug === nextSkill.slug);
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
// New skill discovered — derive key and upsert
|
// New skill discovered — derive key and upsert
|
||||||
nextSkill.key = deriveCanonicalSkillKey(companyId, nextSkill);
|
nextSkill.key = deriveCanonicalSkillKey(companyId, nextSkill);
|
||||||
const persisted = (await upsertImportedSkills(companyId, [nextSkill]))[0];
|
const persisted = (await upsertImportedSkills(companyId, [nextSkill]))[0];
|
||||||
if (persisted) imported.push(persisted);
|
if (persisted) {
|
||||||
|
imported.push(persisted);
|
||||||
|
upsertAcceptedSkill(persisted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user