# All files / dist/indexer-management/resolvers poi-disputes.js

13.79% Statements 4/29
17.65% Branches 3/17
0% Functions 0/17
18.18% Lines 4/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59

    3x

    3x
    3x
    3x

     "use strict";
    /* eslint-disable @typescript-eslint/ban-types */
    var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    Object.defineProperty(exports, "__esModule", { value: true });
    const sequelize_1 = require("sequelize");
    exports.default = {
        dispute: ({ allocationID }, { models }) => __awaiter(void 0, void 0, void 0, function* () {
            const dispute = yield models.POIDispute.findOne({
                where: { allocationID },
            });
            return (dispute === null || dispute === void 0 ? void 0 : dispute.toGraphQL()) || dispute;
        }),
        disputes: ({ status, minClosedEpoch }, { models }) => __awaiter(void 0, void 0, void 0, function* () {
            const disputes = yield models.POIDispute.findAll({
                where: {
                    [sequelize_1.Op.and]: [
                        { status },
                        {
                            closedEpoch: {
                                [sequelize_1.Op.gte]: minClosedEpoch,
                            },
                        },
                    ],
                },
                order: [['allocationAmount', 'DESC']],
            });
            return disputes.map((dispute) => dispute.toGraphQL());
        }),
        storeDisputes: ({ disputes }, { models }) => __awaiter(void 0, void 0, void 0, function* () {
            const createdDisputes = yield models.POIDispute.bulkCreate(disputes, {
                returning: true,
                validate: true,
                updateOnDuplicate: [
                    'closedEpochReferenceProof',
                    'previousEpochReferenceProof',
                    'status',
                ],
            });
            return createdDisputes.map((dispute) => dispute.toGraphQL());
        }),
        deleteDisputes: ({ allocationIDs }, { models }) => __awaiter(void 0, void 0, void 0, function* () {
            const numDeleted = yield models.POIDispute.destroy({
                where: {
                    allocationID: allocationIDs,
                },
                force: true,
            });
            return numDeleted;
        }),
    };
    //# sourceMappingURL=poi-disputes.js.map