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

[bugfix] fix applications results #956

Merged
merged 2 commits into from
Oct 10, 2023
Merged

[bugfix] fix applications results #956

merged 2 commits into from
Oct 10, 2023

Conversation

vibern0
Copy link
Contributor

@vibern0 vibern0 commented Oct 10, 2023

Changes

This PR fixes the response on GET /microcredit/applications so that it includes all the data to be added on the dashboard.

To accommodate that, two new columns were added. The reason behind those two columns was to avoid two LEFT JOINs.

const applications = await models.microCreditApplications.findAndCountAll({
    attributes: ['id', 'amount', 'period', 'status', 'decisionOn', 'createdAt'],
    where,
    include: [
        {
            model: models.appUser,
            as: 'user',
            attributes: ['address', 'firstName', 'lastName', 'avatarMediaPath']
        },
        {
            model: models.microCreditDocs,
            as: 'docs',
            attributes: [],
            // only the document with category type 1 (might not exist)
            where: {
                category: 1
            },
            required: false
        },
        {
            model: models.subgraphMicroCreditBorrowers,
            as: 'borrower',
            attributes: ['claim'],
            required: false
        }
    ],
    order: [[orderKey || 'microCreditApplications.createdAt', orderDirection || 'desc']],
    offset: query.offset,
    limit: query.limit
});

It also changes POST /microcredit/docs, requiring the applicationId.

Tests

@sonarcloud
Copy link

sonarcloud bot commented Oct 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@vibern0 vibern0 merged commit fdc3b4f into main Oct 10, 2023
6 checks passed
@vibern0 vibern0 deleted the fix/applications-results branch October 10, 2023 18:25
@vibern0 vibern0 linked an issue Oct 17, 2023 that may be closed by this pull request
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.

if a user signs the loan contract twice, it saves two contracts
2 participants