MCPcopy Create free account
hub / github.com/dailydotdev/apps / getTopicWeight

Function getTopicWeight

packages/shared/src/features/feedExplain/describe.ts:427–457  ·  view source on GitHub ↗
(
  tag: string,
  explain: FeedItemExplain | null | undefined,
  profile: FeedProfile | undefined,
)

Source from the content-addressed store, hash-verified

425};
426
427export const getTopicWeight = (
428 tag: string,
429 explain: FeedItemExplain | null | undefined,
430 profile: FeedProfile | undefined,
431):
432 | {
433 weight: number;
434 /** What Auto gives it, before the reader's level or weight. */
435 computedWeight: number;
436 isSet: boolean;
437 }
438 | undefined => {
439 // The profile is weighed with the reader's latest levels, the
440 // explanation with the ones the card was ranked on.
441 if (profile) {
442 const interest = profile.interests.find((item) => item.tag === tag);
443 return {
444 weight: interest?.weight ?? 0,
445 computedWeight: interest?.computedWeight ?? 0,
446 isSet: !!interest?.control,
447 };
448 }
449 if (isRankedExplain(explain) && explain.match?.tag === tag) {
450 return {
451 weight: explain.match.weight,
452 computedWeight: explain.match.computed_weight,
453 isSet: !!explain.match.control,
454 };
455 }
456 return undefined;
457};
458
459export interface ScoreFactor {
460 label: string;

Callers 2

FeedExplanationModalFunction · 0.90
SignalRowFunction · 0.90

Calls 1

isRankedExplainFunction · 0.90

Tested by

no test coverage detected