Skip to content

"Relate Donations With Distributed Funds" button function fails #2251

@kkatusic

Description

@kkatusic

Inside AdminJS in QF Rounds History clicking on the "Relate Donations With Distributed Funds" only match total amounts, related distributed amounts donations aren't created inside donations table, function for that is failing.

Here is sample of the error:

{
  "name": "giveth-impact-graph",
  "hostname": "fsdafdasfadsfd",
  "pid": 112,
  "level": 50,
  "msg": "insertDonationsFromQfRoundHistory error QueryFailedError: null value in column \"createdAt\" of relation \"donation\" violates not-null constraint\n    at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async DataSource.query (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:350:20)\n    at async insertDonationsFromQfRoundHistory (/usr/src/app/build/src/services/donationService.js:384:9)\n    at async CreateRelatedDonationsForQfRoundHistoryRecords (/usr/src/app/build/src/server/adminJs/tabs/qfRoundHistoryTab.js:23:5)\n    at async ActionDecorator.handler (/usr/src/app/node_modules/adminjs/lib/backend/decorators/action/action-decorator.js:73:19)\n    at async /usr/src/app/node_modules/@adminjs/express/lib/buildRouter.js:29:22 {\n  query: '\\n' +\n    '         INSERT INTO \"donation\" (\\n' +\n    '            \"transactionId\",\\n' +\n    '            \"transactionNetworkId\",\\n' +\n    '            \"status\",\\n' +\n    '            \"toWalletAddress\",\\n' +\n    '            \"fromWalletAddress\",\\n' +\n    '            \"currency\",\\n' +\n    '            \"amount\",\\n' +\n    '            \"valueUsd\",\\n' +\n    '            \"priceUsd\",\\n' +\n    '            \"powerRound\",\\n' +\n    '            \"projectId\",\\n' +\n    '            \"distributedFundQfRoundId\",\\n' +\n    '            \"segmentNotified\",\\n' +\n    '            \"userId\",\\n' +\n    '            \"createdAt\"\\n' +\n    '        )\\n' +\n    '        SELECT\\n' +\n    '            q.\"distributedFundTxHash\",\\n' +\n    '            CAST(q.\"distributedFundNetwork\" AS INTEGER),\\n' +\n    \"            'verified',\\n\" +\n    '            pa.\"address\",\\n' +\n    '            u.\"walletAddress\",\\n' +\n    '            q.\"matchingFundCurrency\",\\n' +\n    '            q.\"matchingFundAmount\",\\n' +\n    '            q.\"matchingFund\",\\n' +\n    '            q.\"matchingFundPriceUsd\",\\n' +\n    '            100,\\n' +\n    '            q.\"projectId\",\\n' +\n    '            q.\"qfRoundId\",\\n' +\n    '            true,\\n' +\n    '            12103,\\n' +\n    '            q.\"distributedFundTxDate\"\\n' +\n    '        FROM\\n' +\n    '            \"qf_round_history\" q\\n' +\n    '            INNER JOIN \"project\" p ON q.\"projectId\" = p.\"id\"\\n' +\n    '            INNER JOIN \"user\" u ON u.\"id\" = 12103\\n' +\n    '            INNER JOIN \"project_address\" pa ON pa.\"projectId\" = p.\"id\" AND pa.\"networkId\" = CAST(q.\"distributedFundNetwork\" AS INTEGER)\\n' +\n    '        WHERE\\n' +\n    '            q.\"distributedFundTxHash\" IS NOT NULL AND\\n' +\n    '            q.\"matchingFundAmount\" IS NOT NULL AND\\n' +\n    '            q.\"matchingFundCurrency\" IS NOT NULL AND\\n' +\n    '            q.\"distributedFundNetwork\" IS NOT NULL AND\\n' +\n    '            q.\"matchingFund\" IS NOT NULL AND\\n' +\n    '            q.\"matchingFund\" != 0 AND\\n' +\n    '            NOT EXISTS (\\n' +\n    '              SELECT 1\\n' +\n    '              FROM \"donation\" d\\n' +\n    '              WHERE \\n' +\n    '                  d.\"transactionId\" = q.\"distributedFundTxHash\" AND\\n' +\n    '                  d.\"projectId\" = q.\"projectId\" AND\\n' +\n    '                  d.\"distributedFundQfRoundId\" = q.\"qfRoundId\"\\n' +\n    '            )\\n' +\n    '  ',\n  parameters: undefined,\n  driverError: error: null value in column \"createdAt\" of relation \"donation\" violates not-null constraint\n      at Parser.parseErrorMessage (/usr/src/app/node_modules/pg-protocol/dist/parser.js:287:98)\n      at Parser.handlePacket (/usr/src/app/node_modules/pg-protocol/dist/parser.js:126:29)\n      at Parser.parse (/usr/src/app/node_modules/pg-protocol/dist/parser.js:39:38)\n      at TLSSocket.<anonymous> (/usr/src/app/node_modules/pg-protocol/dist/index.js:11:42)\n      at TLSSocket.emit (node:events:518:28)\n      at TLSSocket.emit (node:domain:488:12)\n      at addChunk (node:internal/streams/readable:559:12)\n      at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)\n      at Readable.push (node:internal/streams/readable:390:5)\n      at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) {\n    length: 689,\n    severity: 'ERROR',\n    code: '23502',\n    detail: 'Failing row contains (438226, fdsffsdfdsfdsfsdf, fsdfsdfdsfsdfdsfds, 0x6e8SSSS5170Da467010565968C7C62, USDGLO, null, 5000, 5000, null, 15553, 12103, 1500, null, null, 5000, null, null, verified, null, f, f, null, null, null, t, f, f, f, null, null, null, 100, null, null, null, null, null, f, null, null, null, f, null, null, 15, null, EVM, null, null, null, null, null, f, null, null, f, null, null, f, null, null).',\n    hint: undefined,\n    position: undefined,\n    internalPosition: undefined,\n    internalQuery: undefined,\n    where: undefined,\n    schema: 'public',\n    table: 'donation',\n    column: 'createdAt',\n    dataType: undefined,\n    constraint: undefined,\n    file: 'execMain.c',\n    line: '1981',\n    routine: 'ExecConstraints'\n  },\n  length: 689,\n  severity: 'ERROR',\n  code: '23502',\n  detail: 'Failing row contains (4399226, fsdfsdfdsfds, fsdfsdfdsfsdfdsfdsfdsfds, 0x6e88730855ffffffff010565968C7C62, USDGLO, null, 5000, 5000, null, 15553, 12103, 1500, null, null, 5000, null, null, verified, null, f, f, null, null, null, t, f, f, f, null, null, null, 100, null, null, null, null, null, f, null, null, null, f, null, null, 15, null, EVM, null, null, null, null, null, f, null, null, f, null, null, f, null, null).',\n  hint: undefined,\n  position: undefined,\n  internalPosition: undefined,\n  internalQuery: undefined,\n  where: undefined,\n  schema: 'public',\n  table: 'donation',\n  column: 'createdAt',\n  dataType: undefined,\n  constraint: undefined,\n  file: 'execMain.c',\n  line: '1981',\n  routine: 'ExecConstraints'\n}",
  "time": "2025-10-30T15:59:05.778Z",
  "v
```": 0
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    Status
    New Issues
    Status
    New Issues

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions