- Implemented `useAnalytics` hook for fetching and managing analytics data. - Created `analyticsStore.ts` to handle database queries for hourly stats, topic trends, user leaderboard, and moderation stats. - Added Express routes for analytics endpoints including overview, hourly stats, topic trends, user leaderboard, moderation stats, and top violators. - Introduced a utility function `filterHits` for filtering specific terms in text.
20 lines
718 B
JavaScript
20 lines
718 B
JavaScript
function filterHits(text, hits) {
|
|
const lowerText = text.toLowerCase();
|
|
return hits.filter(hit => {
|
|
if (hit === "asu") {
|
|
const words = lowerText.match(/[\p{L}\p{N}_]+/gu) || [];
|
|
return words.some(w =>
|
|
w.includes("asu") &&
|
|
!["asus", "masuk", "termasuk", "dimasukkan", "memasukkan", "kasur", "asumsi", "asuransi", "asupan", "pasukan", "pasundan"].includes(w)
|
|
);
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
|
|
console.log(filterHits("Gua aja mau membeli asus", ["asu"])); // []
|
|
console.log(filterHits("asus asu", ["asu"])); // ["asu"]
|
|
console.log(filterHits("masuk", ["asu"])); // []
|
|
console.log(filterHits("asuuu", ["asu"])); // ["asu"]
|
|
console.log(filterHits("ngasu", ["asu"])); // ["asu"]
|