(video: Api.Message)
| 541 | if (validVideos.length > 1) { |
| 542 | const queryNormalized = this.normalizeSearchTerm(query || ""); |
| 543 | const getScore = (video: Api.Message): number => { |
| 544 | let score = 0; |
| 545 | const fileNameAttr = video.video?.attributes.find((attr: any): attr is Api.DocumentAttributeFilename => attr instanceof Api.DocumentAttributeFilename); |
| 546 | if (fileNameAttr?.fileName) { |
| 547 | const normalizedFileName = this.normalizeSearchTerm(fileNameAttr.fileName); |
| 548 | if (normalizedFileName.includes(queryNormalized)) score += 100; |
| 549 | } |
| 550 | if (video.message) { |
| 551 | const normalizedMessage = this.normalizeSearchTerm(video.message); |
| 552 | if (normalizedMessage.includes(queryNormalized)) score += 50; |
| 553 | } |
| 554 | return score; |
| 555 | }; |
| 556 | |
| 557 | validVideos.sort((a, b) => { |
| 558 | const scoreA = getScore(a); |
nothing calls this directly
no test coverage detected