Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Pages order info #2104

wants to merge 3 commits into from

Conversation

erikaas24
Copy link
Contributor

Changes

What has been done

  • I have added parameters to the query and backend so that we can ask for specific parts of the Orders-data
  • Updated front-end to support pagination
  • Adjusted some CSS on the front-end

Copy link

vercel bot commented Oct 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
indok-web ❌ Failed (Inspect) Oct 17, 2024 4:19pm

Copy link

sonarcloud bot commented Oct 17, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 83.16%. Comparing base (1993cc0) to head (3edf0e5).

Files with missing lines Patch % Lines
backend/apps/ecommerce/resolvers.py 14.28% 6 Missing ⚠️
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     
Flag Coverage Δ
apitests 83.16% <25.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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:
Copy link
Contributor

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';
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name changed, comment removed

Copy link
Contributor

@MagnusHafstad MagnusHafstad left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants