Skip to content

created Api to get seller profile#16

Open
KAMALDEEN333 wants to merge 1 commit intoRegen-Bazaar:mainfrom
KAMALDEEN333:Seller-Profile
Open

created Api to get seller profile#16
KAMALDEEN333 wants to merge 1 commit intoRegen-Bazaar:mainfrom
KAMALDEEN333:Seller-Profile

Conversation

@KAMALDEEN333
Copy link

Created API to Get All Seller Created project, Sold Projects and other activity accordingly

@KAMALDEEN333
Copy link
Author

@pratiksardar a pr has been sent kindly review

@pratiksardar
Copy link
Member

can you create a postman collection or something so It's easy to understand the implementation , args and etc

@pratiksardar pratiksardar requested a review from Copilot August 13, 2025 03:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new seller profile API that allows users to retrieve information about their projects and sales activity. The implementation adds comprehensive seller-related endpoints to track project creation, sales, and transaction history.

Key changes:

  • Created new seller routes with authentication middleware for project management endpoints
  • Extended the Transaction model to support project sales tracking with seller and project references
  • Added a new Project model to represent sellable items with status tracking

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/routes/seller.js New route file defining seller-specific endpoints with authentication
src/routes/index.js Integration of seller routes into the main API routing structure
src/models/Transaction.js Enhanced transaction model to support project sale tracking
src/models/Project.js New project model for managing sellable items and their lifecycle
src/controllers/sellerController.js Business logic for seller profile endpoints including projects and activity

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

createdAt: {
type: Date,
default: Date.now,
},
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The timestamps option is redundant since you already have explicit createdAt field. Either remove the explicit createdAt field and rely on timestamps: true, or remove the timestamps option to avoid confusion.

Suggested change
},

Copilot uses AI. Check for mistakes.
Project.find({ seller: sellerId }),
Transaction.find({ seller: sellerId, type: 'project_sale' }).populate('project'),
Transaction.find({ seller: sellerId })
]);
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The getSellerActivity function performs redundant queries. The soldProjects query is a subset of the transactions query (transactions with type: 'project_sale'), so you could filter the transactions result instead of making a separate database call.

Suggested change
]);
const [projects, transactions] = await Promise.all([
Project.find({ seller: sellerId }),
Transaction.find({ seller: sellerId }).populate('project')
]);
const soldProjects = transactions.filter(tx => tx.type === 'project_sale');

Copilot uses AI. Check for mistakes.
try {
const sellerId = req.user.id;

const soldProjects = await Transaction.find({ seller: sellerId, type: 'project_sale' }).populate('project');
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

[nitpick] The API returns Transaction objects for sold projects, but users might expect Project objects with sale information. Consider restructuring to return projects with their sale transaction details instead.

Suggested change
const soldProjects = await Transaction.find({ seller: sellerId, type: 'project_sale' }).populate('project');
const soldTransactions = await Transaction.find({ seller: sellerId, type: 'project_sale' }).populate('project');
const soldProjects = soldTransactions
.filter(tx => tx.project) // Ensure project is populated
.map(tx => {
const projectObj = tx.project.toObject ? tx.project.toObject() : { ...tx.project };
projectObj.saleInfo = {
transactionId: tx._id,
soldAt: tx.createdAt,
price: tx.amount,
buyer: tx.buyer,
// add other relevant transaction fields as needed
};
return projectObj;
});

Copilot uses AI. Check for mistakes.
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.

3 participants