Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2023-02-15 09:14:20 +06:00
committed by GitHub
parent aa8530d678
commit 199da5077a
71 changed files with 888 additions and 312 deletions
+2 -1
View File
@@ -9,7 +9,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
@@ -210,12 +210,9 @@
async function onMessage (event: CustomEvent) {
loading = true
try {
await createAttachments()
dispatch('message', { message: event.detail, attachments: attachments.size })
} finally {
loading = false
}
await createAttachments()
loading = false
dispatch('message', { message: event.detail, attachments: attachments.size })
}
async function onUpdate (event: CustomEvent) {
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+1 -1
View File
@@ -23,7 +23,7 @@
"eslint-config-standard-with-typescript": "^23.0.0",
"prettier": "^2.7.1",
"@rushstack/heft": "^0.47.9",
"typescript": "^4.3.5",
"typescript": "^4.3.5",
"@types/qs": "~6.9.7"
},
"dependencies": {
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
@@ -112,29 +112,26 @@
async function onMessage (event: CustomEvent) {
loading = true
try {
const { message, attachments } = event.detail
await client.addCollection<Doc, Comment>(
_class,
object.space,
object._id,
object._class,
'comments',
{ message, attachments },
_id
)
const { message, attachments } = event.detail
await client.addCollection<Doc, Comment>(
_class,
object.space,
object._id,
object._class,
'comments',
{ message, attachments },
_id
)
// Create an backlink to document
await createBacklinks(client, object._id, object._class, _id, message)
// Create an backlink to document
await createBacklinks(client, object._id, object._class, _id, message)
// Remove draft from Local Storage
_id = generateId()
draftComment = undefined
await saveDraft(object)
commentInputBox.removeDraft(false)
} finally {
loading = false
}
// Remove draft from Local Storage
_id = generateId()
draftComment = undefined
await saveDraft(object)
commentInputBox.removeDraft(false)
loading = false
}
</script>
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -9,7 +9,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
@@ -5,15 +5,15 @@
Card,
createQuery,
getClient,
IndexedDocumentPreview,
IndexedDocumentCompare,
MessageViewer,
SpaceSelect
} from '@hcengineering/presentation'
import { Applicant, ApplicantMatch, Candidate, Vacancy } from '@hcengineering/recruit'
import { Button, IconActivity, IconAdd, Label, resizeObserver, showPopup, tooltip } from '@hcengineering/ui'
import { Button, IconActivity, IconAdd, Label, resizeObserver, showPopup, Spinner, tooltip } from '@hcengineering/ui'
import Scroller from '@hcengineering/ui/src/components/Scroller.svelte'
import { MarkupPreviewPopup, ObjectPresenter } from '@hcengineering/view-resources'
import { cosinesim } from '@hcengineering/view-resources/src/utils'
import { calcSørensenDiceCoefficient, cosinesim } from '@hcengineering/view-resources/src/utils'
import { createEventDispatcher } from 'svelte'
import recruit from '../plugin'
import CreateApplication from './CreateApplication.svelte'
@@ -50,8 +50,20 @@
state = new Map(res.map((it) => [it._id, it] ?? []))
}
)
$: vacancyState = state.get(_space as unknown as Ref<DocIndexState>)
$: scoreState = new Map(
_objects.map((it) => [
it._id,
Math.round(
calcSørensenDiceCoefficient(state.get(it._id)?.fullSummary ?? '', vacancyState?.fullSummary ?? '') * 100
) / 100
])
)
$: _sortedObjects = [..._objects].sort((a, b) => (scoreState.get(b._id) ?? 0) - (scoreState.get(a._id) ?? 0))
const matchQuery = createQuery()
let matches: Map<Ref<Doc>, ApplicantMatch> = new Map()
@@ -88,6 +100,7 @@
}
}
$: vacancyEmbedding = vacancyState && getEmbedding(vacancyState)
const dispatch = createEventDispatcher()
const client = getClient()
@@ -126,8 +139,8 @@
'top'
)
}
async function showSummary (doc: Candidate): Promise<void> {
showPopup(IndexedDocumentPreview, { objectId: doc._id }, 'top')
async function showSummary (left: DocIndexState, right?: DocIndexState): Promise<void> {
showPopup(IndexedDocumentCompare, { left, right }, 'top')
}
</script>
@@ -172,7 +185,7 @@
<div class="p-1">
{#if vacancy}
<Scroller>
<div class="flex-col max-h-60">
<div class="flex-col max-h-60 select-text">
{#if vacancy.description}
{vacancy.description}
{/if}
@@ -197,7 +210,7 @@
</thead>
<tbody>
{#each _objects as doc}
{#each _sortedObjects as doc}
{@const docState = state.get(doc._id)}
{@const docEmbedding = docState && getEmbedding(docState)}
{@const match = matches.get(doc._id)}
@@ -213,10 +226,12 @@
{/if}
</div>
</td>
<td>
<td class="whitespace-nowrap">
{#if docEmbedding && vacancyEmbedding}
{Math.round(cosinesim(docEmbedding, vacancyEmbedding) * 100)}
/
{/if}
{scoreState.get(doc._id) ?? 0}
</td>
<td>
{#if match?.complete}
@@ -232,13 +247,13 @@
{#if docState}
<Button
label={recruit.string.PerformMatch}
loading={matching.has(doc._id) || !(match?.complete ?? true)}
icon={matching.has(doc._id) || !(match?.complete ?? true) ? Spinner : IconActivity}
on:click={() => requestMatch(doc, docState)}
/>
<Button
icon={IconActivity}
showTooltip={{ label: presentation.string.DocumentPreview }}
on:click={() => showSummary(doc)}
on:click={() => showSummary(docState, vacancyState)}
/>
<Button
icon={IconAdd}
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+1 -1
View File
@@ -38,4 +38,4 @@
"publishConfig": {
"registry": "https://npm.pkg.github.com"
}
}
}
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"svelte-check": "svelte-check"
"svelte-check": "svelte-check",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"@hcengineering/platform-rig": "^0.6.0",
+2 -1
View File
@@ -10,7 +10,8 @@
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"svelte-check": "svelte-check",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",
@@ -29,8 +29,10 @@
dispatch('changeContent')
}}
on:close={() => dispatch('close', null)}
style:overflow={'auto'}
style:width={'100%'}
>
<div class="flex-grow mt-4">
<div class="flex-grow p-4">
<MessageViewer message={value} />
</div>
</div>
+32
View File
@@ -601,6 +601,38 @@ export function cosinesim (A: number[], B: number[]): number {
return similarity
}
/**
* Calculate Sørensen–Dice coefficient
*/
export function calcSørensenDiceCoefficient (a: string, b: string): number {
const first = a.replace(/\s+/g, '')
const second = b.replace(/\s+/g, '')
if (first === second) return 1 // identical or empty
if (first.length < 2 || second.length < 2) return 0 // if either is a 0-letter or 1-letter string
const firstBigrams = new Map<string, number>()
for (let i = 0; i < first.length - 1; i++) {
const bigram = first.substring(i, i + 2)
const count = (firstBigrams.get(bigram) ?? 0) + 1
firstBigrams.set(bigram, count)
}
let intersectionSize = 0
for (let i = 0; i < second.length - 1; i++) {
const bigram = second.substring(i, i + 2)
const count = firstBigrams.get(bigram) ?? 0
if (count > 0) {
firstBigrams.set(bigram, count - 1)
intersectionSize++
}
}
return (2.0 * intersectionSize) / (first.length + second.length - 2)
}
/**
* @public
*/
+2 -1
View File
@@ -9,7 +9,8 @@
"build:docs": "api-extractor run --local",
"lint": "svelte-check && eslint",
"lint:fix": "eslint --fix src",
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src"
"format": "prettier --write --plugin-search-dir=. src && eslint --fix src",
"build:watch": "tsc --incremental --noEmit --outDir ./dist_cache"
},
"devDependencies": {
"svelte-loader": "^3.1.3",