2018-06-11 20:36:32 +02:00
|
|
|
const db = require('../../../../models');
|
2018-09-26 03:20:59 +02:00
|
|
|
const chainquery = require('chainquery');
|
|
|
|
const getClaimData = require('server/utils/getClaimData');
|
2018-04-27 18:54:36 +02:00
|
|
|
const { returnPaginatedChannelClaims } = require('./channelPagination.js');
|
|
|
|
|
2018-09-26 03:20:59 +02:00
|
|
|
const getChannelClaims = async (channelName, channelShortId, page) => {
|
|
|
|
const channelId = await chainquery.claim.queries.getLongClaimId(channelName, channelShortId);
|
|
|
|
const channelClaims = await chainquery.claim.queries.getAllChannelClaims(channelId);
|
|
|
|
|
2018-10-10 18:28:53 +02:00
|
|
|
const processingChannelClaims = channelClaims ? channelClaims.map((claim) => getClaimData(claim)) : [];
|
|
|
|
const processedChannelClaims = await Promise.all(processingChannelClaims);
|
2018-09-26 03:20:59 +02:00
|
|
|
|
|
|
|
return returnPaginatedChannelClaims(channelName, channelId, processedChannelClaims, page);
|
2018-04-27 18:54:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = getChannelClaims;
|