Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6624357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:38:34+00:00 2026-05-25T21:38:34+00:00

I have a dashboard for real-time updates and latest notifications. Imagine this is a

  • 0

I have a dashboard for real-time updates and latest notifications.

Imagine this is a blogging system where you can subscribe to authors posts and comments.
I then want 2 type of notifications to appear in my dashboard, sorted by insertion time:

  1. Last posts
  2. Last comments

Imagine I only want 10 updates to show up when I load the dashboard (later updtes I’m getting through ajax). How should I query the database and how should I sort the results?

I’ve thought of querying the 2 tables (posts and comments) for data that I’ve subscribed, add that data to a list and sort those results for datetime and then return the last 10, but I feel this is not a very good solution since it would take lots of time to sort if those tables (and my subscriptions) begin to grow.

What are your answers/thoughts for this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:38:34+00:00Added an answer on May 25, 2026 at 9:38 pm

    Query the first table ordering by descending insertion time and limiting results to 10. Then query the second table the same way. Then merge results in python and return the first 10 of them.

    A django example could look like this:

    from operator import attrgetter
    
    recent_posts = Post.objects.order_by('-created')[:10]
    recent_comments = Comment.objects.order_by('-created')[:10]
    both_combined = list(recent_posts) + list(recent_comments)
    both_sorted = sorted(both_combined, key=attrgetter('created'), reverse=True)
    most_recent = both_sorted[:10]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have grid something like this: Ext.define('Exp.view.dashboard.Tv', { extend: 'Ext.grid.Panel', initComponent: function() { this.columns
I understand that Primefaces Layout and Dashboard have state which can be saved. Could
I have a dashboard page that has(or moreover can have) multiple charts that are
This is an Objective-C/iphone SDK question. I have a dashboard view that is used
I have a dashboard with users details which they can edit. I would like
I have a dashboard page where the user can enter an asset code or
I have a dashboard in my website which contain some entries in table, each
I have a dashboard at work and I want people to be able to
I have a dashboard which contains around 16 graphs. All the settings of the
I have to develop a dashboard widget for Mac Osx to support 32/64 bit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.