question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filtering on weeknumbers greater then 10 doesn't return results

See original GitHub issue

I’m having a table of around 4000 recipes. Every recipe has a weeknumber.

When I run:

this.apiService.ListRecipes({ weeknumber: { eq: moment().week() } }, 4000)

I get zero results sinds it is currently week 20

It only works when entering a static number between 1 and 10. My table Recipes has also records with weeknumbers between 11 and 52

Another unexpected behavior is, that it is performing the limit: 4000 before filtering the weeknumbers.

I was expecting it would first ask the database for all entries with weeknumber X and then limit the results.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
vparpoilcommented, May 16, 2019

If you need to download 5MB of data, you can use a recursive approach. Here is a draft of how it looks like:

let allRecipes = []
let search = {limit: 100000}
const recursiveGetRecipes = (currentResult) => {
    // if first iteration or if there is a next Token
    if (currentResult === null || currentResult.nextToken != null) {
        if (currentResult !== null && currentResult.nextToken != null) {
           // other iterations
            search.nextToken = currentResult.nextToken
        }
        API.graphql(graphqlOperation(listRecipes, search)).then((result) => {
            currentResult = result.data.listRecipes;
            allRecipes = allRecipes.concat(currentResult.items);
            this.recursiveGetRecipes(currentResult)
        }).catch((error) => {
            // error
        })
    } else {
        // done
    }
}
recursiveGetRecipes(null);
1reaction
sprucifycommented, May 16, 2019

Ok the dynamoDB scan function indeed first limits the results and apply the filtering on that subset, this is not a very helpful order in my opinion.

In a response, DynamoDB returns all the matching results within the scope of the Limit value. For example, if you issue a Query or a Scan request with a Limit value of 6 and without a filter expression, DynamoDB returns the first six items in the table that match the specified key conditions in the request (or just the first six items in the case of a Scan with no filter). If you also supply a FilterExpression value, DynamoDB will return the items in the first six that also match the filter requirements (the number of results returned will be less than or equal to 6).

You wouldn’t believe the reason behind why I’m only getting back records for week 1 to 10. My total table size is 5,56MB Divide this bij 52 weeks and I’m on 0.1MB per week. Times 10 and I’m on 1MB which is unbelievable the maximum data size for the scan operation!

This took me 11 hours of debugging to find the reason.

So how on earth are other companies getting API’s build with all these limits?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filtering by Week Number over Multiple Week Number Columns
Hi there, I'm relativley new to Power BI and i'm trying to create a report from a Sharepoint site list. The report is...
Read more >
How To Obtain Previous Week Values In Power BI - YouTube
Retrieving previous period values in Power BI is a common task, but retrieving previous week values requires some special attention.
Read more >
Date criteria doesn't work in my query - Microsoft Support
All dates. The criteria is missing the "And" operator, so it doesn't filter any results out. Dates on or after 1/1/05 and on...
Read more >
How to Create a Week Number Filter with Date Range in ...
Right-click on Week with Date Ranges in Filters, then select Show Filter. Click on the down arrow located on the top right corner...
Read more >
Filtering With Dates In The QUERY Function - - Ben Collins
This post explores this issue in more detail and shows you how to filter with dates correctly in your Query formulas. The problem....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found