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

Add community stats #589

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions bot/modules/community/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ exports.onCommunityInfo = async ctx => {
const orderCount = await getOrdersNDays(1, commId);
const volume = await getVolumeNDays(1, commId);

const creator = await User.findById(community.creator_id);

let orderChannelsText = '';
if (community.order_channels.length === 1) {
orderChannelsText = `${community.order_channels[0].name} (${community.order_channels[0].type})`;
} else if (community.order_channels.length === 2) {
orderChannelsText = `${community.order_channels[0].name} (${community.order_channels[0].type}) ${community.order_channels[1].name} (${community.order_channels[1].type})`;
}

const options = { year: 'numeric', month: 'short', day: 'numeric' };
const formatDate = community.created_at.toLocaleDateString('en-US', options);

const rows = [];
rows.push([
{ text: ctx.i18n.t('orders') + ' 24hs', callback_data: 'none' },
Expand All @@ -62,13 +74,14 @@ exports.onCommunityInfo = async ctx => {
{ text: ctx.i18n.t('users'), callback_data: 'none' },
{ text: userCount, callback_data: 'none' },
]);

rows.push([
{
text: ctx.i18n.t('use_default'),
callback_data: `setCommunity_${commId}`,
},
]);
const text = `${community.name}\n${community.group}`;
const text = `${community.name}: ${community.group} \nCreator: @${creator.username} \nOrder Channels: ${orderChannelsText} \nFee: ${community.fee} \nCreated At: ${formatDate}`;
await ctx.reply(text, {
reply_markup: { inline_keyboard: rows },
});
Expand All @@ -90,4 +103,4 @@ exports.withdrawEarnings = async ctx => {
ctx.scene.enter('ADD_EARNINGS_INVOICE_WIZARD_SCENE_ID', {
community,
});
};
};
Loading