-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pages order info #2104
base: main
Are you sure you want to change the base?
Pages order info #2104
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2104 +/- ##
==========================================
- Coverage 83.28% 83.16% -0.13%
==========================================
Files 100 100
Lines 3572 3576 +4
==========================================
- Hits 2975 2974 -1
- Misses 597 602 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
orders = Order.objects.filter(product__shop_item=True).order_by('delivered_product', 'payment_status', 'timestamp') | ||
if offset is not None: | ||
orders = orders[offset:] | ||
if limit is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you instead of this add a max of 300 to limit. So if I set it ti 400 it caps at 300 instead. This is to prevent someone from unknowingly crashing the thing later. Also add a short comment on why it is capped at 300 as it won't be obvious to anyone not extreamly familiar with our system
import { ShopSale } from "../orgs/ShopSale"; | ||
import React,{ useState } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the "React," it is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
||
type Props = { | ||
organization: AdminOrganizationFragment; | ||
}; | ||
export const OrgProducts: React.FC<Props> = ({ organization }) => { | ||
const { data, error } = useQuery(AllShopOrdersDocument); | ||
|
||
const limit = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember that when this is merged it will be in production so remember to change this from 5 to something like 100 before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
const prevPage = () => setPage(page > 0 ? page - 1 : 0); | ||
const theme = useTheme(); | ||
// Check if there is a next page (if we received less than `limit` items) | ||
const hasNextPage = (data?.allShopOrders && data.allShopOrders.length < limit) ?? false; //Have to check if the data exists before I check that the data has a certain length. This gave me an error: data?.allShopOrders?.length < limit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is not needed here. Also this is an example of why the query should be renamed. When it is called allShopOrders it seems like you have a bug here, but i dont think you actually do because data.allShopOrders isn't actually all the shop orders but rather the ones in the current query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name changed, comment removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rename the allShopOrders query
Changes
What has been done