Score:0

"Most popular" tags of the day

za flag

How can I create a list of the most popular tags of the day, based on the actual date, using view?

The most voted answer for Most popular tags in a list as a block helped me to set a list of the "most popular" tags using contextual filters and aggregation, but I couldn't find a way to show only the tags of the day.

Can you help me?

Score:1
de flag

I've built something similiar to this in the past with Redis. Each time a 'tag' is hit, it gets one point. Every hour, the value of all scores, for everything hit ever is dropped by 10%. Then you order by points.

So a tag that gets hit 10 times in the first hour, will have 10 points. After an hour, those points are degraded 10%, leaving 9 points. An hour later, it's 8.1 points, then 7.2 points and so on. Of course, more views adds more points.

Since all scores are degraded 10% every hour, the value of previous hits received drops over time, and anything that is being hit regularly, or even going viral, will have more undegraded points.

In Drupal terms for example, consider a tag that is a taxonomy term attached to a comment. When new comments are saved, you can loop through any attached terms in hook_comment_insert() to add a point for each tag:

function HOOK_comment_insert(\Drupal\Core\Entity\EntityInterface $comment) {
  foreach ($comment->get('field_tag')->value as $tag) {
    some_php_function_that_adds_a_point_for_a_tag_in_reds($tag);
  }
}

Then, you would want to create a cron implementation that degrades the points stored in Redis:

function HOOK_cron() {
  some_function_that_deletes_all_tag_scores_by_10_percent();
}

And you set the cron to run every hour. Although, in a real-world setting, I would actually integrate my module with the Ultimate Cron module for more granular control over cron runs, to better ensure that my process is run every hour.

esQmo_ avatar
za flag
Hey, I never used Redis, first time to hear about it though. Can you explain how to achieve it?
Jaypan avatar
de flag
Redis is a key:value storage system, that I believe keeps its memory in storage. It's very fast. There is a redis integration module, and Drupal-specific hosts will provide Redis integration. As for setting up the above, it's more than I could explain in a thread, which is why I only gave the overview. I'll add a bit to the post though.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.