Commit aae54743 authored by gongguan's avatar gongguan

修改数据需求的获取形式

parent 1df4d685
......@@ -68,25 +68,21 @@ export default class StatService {
const endDayTimestamp = formatDate(endDay).getTimestamp()
while (curDayTimestamp <= endDayTimestamp) {
// 访问PV
const PV = await this.accessdao.count({ activityId, createDay: day })
const PVpromise = this.accessdao.count({ activityId, createDay: day })
// 访问UV
const UV = await this.userdao.count({ activityId, [`login.${day}`]: { $exists: true } })
const UVpromise = this.userdao.count({ activityId, [`login.${day}`]: { $exists: true } })
// 新增UV
const newUV = await this.userdao.count({ activityId, createDay: day })
// 新增PV
// const newPV = await this.userdao.count({ activityId, createDay: day })
const newUVpromise = this.userdao.count({ activityId, createDay: day })
// 新增UV(通过邀请)
const newUVFromInviteUV = (
await this.accessdao.aggregate([
const newUVFromInviteUVpromise = this.accessdao.aggregate([
{ $match: { activityId, createDay: day, inviteId: { $exists: true } } },
{ $project: { openId: true } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])
).length
// 已入会(老会员)PV
const vipPV = await this.accessdao.count({
const vipPVpromise = this.accessdao.count({
activityId,
createDay: day,
//@ts-ignore
......@@ -95,7 +91,7 @@ export default class StatService {
})
// 已入会(老会员)UV
const vipUV = await this.userdao.count({
const vipUVpromise = this.userdao.count({
activityId,
[`login.${day}`]: { $exists: true },
$or: [
......@@ -107,30 +103,26 @@ export default class StatService {
})
// 未入会PV
const noVipPV = await this.accessdao.count({ activityId, createDay: day, isVip: false })
const noVipPVpromise = this.accessdao.count({ activityId, createDay: day, isVip: false })
// 未入会UV
const noVipUV = (
await this.accessdao.aggregate([
const noVipUVpromise = this.accessdao.aggregate([
{ $match: { activityId, createDay: day, isVip: false } },
{ $project: { openId: true } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])
).length
// 新增入会UV
const newVipUV = await this.userdao.count({ activityId, 'member.newMember': true, 'member.bememberDay': day })
const newVipUVpromise = this.userdao.count({ activityId, 'member.newMember': true, 'member.bememberDay': day })
const newFollowUV = await this.userdao.count({ activityId, 'follow.newFollow': true, 'follow.followDay': day })
const newFollowUVpromise = this.userdao.count({ activityId, 'follow.newFollow': true, 'follow.followDay': day })
// 助力成功UV
const helpSuccessUV = (
await this.statdao.aggregate([
const helpSuccessUVpromise = this.statdao.aggregate([
{ $match: { activityId, createDay: day, type: STAT_TYPE.INITE_SUCCESS } },
{ $project: { openId: true } },
{ $group: { _id: '$openId', count: { $sum: 1 } } }
])
).length
// 根据任务类型获取完成任务的人数
// example: await getTaskCompleteUV('collectGoods', day)
......@@ -141,22 +133,48 @@ export default class StatService {
})
}
const [
PV,
UV,
newUV,
newUVFromInviteUV,
vipPV,
vipUV,
noVipPV,
noVipUV,
newVipUV,
newFollowUV,
helpSuccessUV,
] = await Promise.all([
PVpromise,
UVpromise,
newUVpromise,
newUVFromInviteUVpromise,
vipPVpromise,
vipUVpromise,
noVipPVpromise,
noVipUVpromise,
newVipUVpromise,
newFollowUVpromise,
helpSuccessUVpromise,
])
const keyValueMapper = {
时间: day,
访问PV: PV,
访问UV: UV,
新增UV: newUV,
'新增UV(通过邀请)': newUVFromInviteUV,
'新增UV(通过邀请)': newUVFromInviteUV.length,
'已入会(老会员)PV': vipPV,
'已入会(老会员)UV': vipUV,
未入会PV: noVipPV,
未入会UV: noVipUV,
未入会UV: noVipUV.length,
新入会UV: newVipUV,
新增关注UV: newFollowUV,
助力成功UV: helpSuccessUV
助力成功UV: helpSuccessUV.length
//收藏商品任务完成UV: await getTaskCompleteUV('collectGoods', day)
}
console.log(keyValueMapper, 'xlsxData')
console.log('keyValueMapper::::::::::', keyValueMapper)
if (day === startDay) {
xlsxData.push(Object.keys(keyValueMapper))
......@@ -167,6 +185,7 @@ export default class StatService {
curDayTimestamp = tommorrow
day = dateFormatter(transformBeijingDate(tommorrow), 'yyyy/MM/dd')
}
console.log('xlsxData::::::::::', xlsxData)
return xlsxData
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment