remove deprecated code

This commit is contained in:
2026-01-07 00:07:19 -05:00
parent 5e247e54cb
commit b04b5a8022
3 changed files with 0 additions and 111 deletions

View File

@@ -43,101 +43,6 @@ export function getCommentLevel(
return level;
}
/**
* @deprecated Server-side SQL sorting preferred for performance
* Logarithmic decay formula: score / log(age + 2)
*/
function calculateHotScore(
upvotes: number,
downvotes: number,
date: string
): number {
const score = upvotes - downvotes;
const now = new Date().getTime();
const commentTime = new Date(date).getTime();
const ageInHours = (now - commentTime) / (1000 * 60 * 60);
return score / Math.log10(ageInHours + 2);
}
/**
* @deprecated Server-side SQL sorting preferred for performance
*/
function getUpvoteCount(
commentID: number,
reactionMap: Map<number, CommentReaction[]>
): number {
const reactions = reactionMap.get(commentID) || [];
return reactions.filter(
(r) => r.type === "tears" || r.type === "heartEye" || r.type === "moneyEye"
).length;
}
/**
* @deprecated Server-side SQL sorting preferred for performance
*/
function getDownvoteCount(
commentID: number,
reactionMap: Map<number, CommentReaction[]>
): number {
const reactions = reactionMap.get(commentID) || [];
return reactions.filter(
(r) => r.type === "angry" || r.type === "sick" || r.type === "worried"
).length;
}
/**
* @deprecated Use server-side SQL sorting in routes/blog/[title]/index.tsx for better performance
*/
export function sortComments(
comments: Comment[],
mode: SortingMode,
reactionMap: Map<number, CommentReaction[]>
): Comment[] {
const sorted = [...comments];
switch (mode) {
case "newest":
return sorted.sort((a, b) => {
return new Date(b.date).getTime() - new Date(a.date).getTime();
});
case "oldest":
return sorted.sort((a, b) => {
return new Date(a.date).getTime() - new Date(b.date).getTime();
});
case "highest_rated":
return sorted.sort((a, b) => {
const upVotesA = getUpvoteCount(a.id, reactionMap);
const downVotesA = getDownvoteCount(a.id, reactionMap);
const upVotesB = getUpvoteCount(b.id, reactionMap);
const downVotesB = getDownvoteCount(b.id, reactionMap);
const scoreA = upVotesA - downVotesA;
const scoreB = upVotesB - downVotesB;
return scoreB - scoreA;
});
case "hot":
return sorted.sort((a, b) => {
const upVotesA = getUpvoteCount(a.id, reactionMap);
const downVotesA = getDownvoteCount(a.id, reactionMap);
const upVotesB = getUpvoteCount(b.id, reactionMap);
const downVotesB = getDownvoteCount(b.id, reactionMap);
const hotScoreA = calculateHotScore(upVotesA, downVotesA, a.date);
const hotScoreB = calculateHotScore(upVotesB, downVotesB, b.date);
return hotScoreB - hotScoreA;
});
default:
return sorted;
}
}
export function isValidCommentBody(body: string): boolean {
return body.trim().length > 0 && body.length <= 10000;
}