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 546571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:52:51+00:00 2026-05-13T10:52:51+00:00

I am using the following class to store some data: class NewsArticle(db.Model): score =

  • 0

I am using the following class to store some data:

class NewsArticle(db.Model):
    score = db.FloatProperty(default=0.0)
    date_scored = db.DateTimeProperty()
    ...

What I need to do is to get those NewsArticle entities that have the top score in some time frame (e.g. get the top scored data entities of today or of last week).

I tried the following:

query = db.GqlQuery('SELECT * FROM NewsArticle WHERE date_created > DATETIME(:year, :month, :day, 0, 0, 0) ORDER BY score DESC', year=date.selected_year, month=date.selected_month, day=date.selected_day)

But that doesn’t work since the datastore requires that the

first ordering property must be the
same as inequality filter property

I thought about getting all NewsArticle entities for a specific timeframe and then doing the score-sorting in my application, but I am expecting a really large number of results so in-memory-sorting won’t be efficient.

What other solutions are possible for my 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-13T10:52:52+00:00Added an answer on May 13, 2026 at 10:52 am

    You could either:

    1. filter only by the timeframe and sort by score in memory or,

    2. if you can limit the timeframes to whole days and weeks, include additional properties in your model to save the the week as a integer and the day as a DateProperty and do a simple equality check on that.

    EDIT: To learn more, have a look at Restrictions on Queries

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using IsolatedStorageSettings class to store some application data that should be retained
For my app i'm using a MVC-Store model. The class DataStore holds a singleton
I am using the following UnitOfWork class in order to get repositories for my
I am using following class to show a grid like appearance with pagination on
I am compressing an image using following class.. <?php class SimpleImage { var $image;
I am using the following class written by Mark Brittingham for two way AES
I am using following prepared statement : Class.forName(com.mysql.jdbc.Driver); con=DriverManager.getConnection(jdbc:mysql://localhost:3306/mysql,root,root); String query=select ename from ?
I am using the following code class AddTask extends AsyncTask<Void, Void, Void> { ProgressDialog
I am trying to register the following class using the fluent interface: public class
I'm using the following mapping: public class LoadMap : IAutoMappingOverride<Load> { public void Override(AutoMapping<Load>

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.