mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Added ability to filter members on conversion attribution
refs https://github.com/TryGhost/Team/issues/1830
This commit is contained in:
parent
83f2bf4757
commit
73466c1c40
@ -43,6 +43,9 @@ const Member = ghostBookshelf.Model.extend({
|
||||
}, {
|
||||
key: 'signup',
|
||||
replacement: 'signups.attribution_id'
|
||||
}, {
|
||||
key: 'conversion',
|
||||
replacement: 'conversions.attribution_id'
|
||||
}];
|
||||
},
|
||||
|
||||
@ -83,6 +86,12 @@ const Member = ghostBookshelf.Model.extend({
|
||||
tableNameAs: 'signups',
|
||||
type: 'oneToOne',
|
||||
joinFrom: 'member_id'
|
||||
},
|
||||
conversions: {
|
||||
tableName: 'members_subscription_created_events',
|
||||
tableNameAs: 'conversions',
|
||||
type: 'oneToOne',
|
||||
joinFrom: 'member_id'
|
||||
}
|
||||
};
|
||||
},
|
||||
|
@ -1929,6 +1929,56 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API Can filter by signup attribution 3: [body] 1`] = `
|
||||
Object {
|
||||
"members": Array [
|
||||
Object {
|
||||
"avatar_image": null,
|
||||
"comped": false,
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"email": "member1@test.com",
|
||||
"email_count": 0,
|
||||
"email_open_rate": null,
|
||||
"email_opened_count": 0,
|
||||
"geolocation": null,
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"labels": Any<Array>,
|
||||
"last_seen_at": null,
|
||||
"name": "Mr Egg",
|
||||
"newsletters": Any<Array>,
|
||||
"note": null,
|
||||
"status": "free",
|
||||
"subscribed": true,
|
||||
"subscriptions": Any<Array>,
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||
},
|
||||
],
|
||||
"meta": Object {
|
||||
"pagination": Object {
|
||||
"limit": 15,
|
||||
"next": null,
|
||||
"page": 1,
|
||||
"pages": 1,
|
||||
"prev": null,
|
||||
"total": 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API Can filter by signup attribution 4: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": "1379",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Members API Can filter on newsletter slug 1: [body] 1`] = `
|
||||
Object {
|
||||
"members": Array [
|
||||
|
@ -234,6 +234,17 @@ describe('Members API', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Can filter by signup attribution', async function () {
|
||||
await agent
|
||||
.get('/members/?filter=conversion:' + fixtureManager.get('posts', 0).id)
|
||||
.expectStatus(200)
|
||||
.matchBodySnapshot({
|
||||
members: new Array(1).fill(memberMatcherShallowIncludes)
|
||||
})
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyEtag
|
||||
});
|
||||
});
|
||||
|
||||
it('Can browse with search', async function () {
|
||||
await agent
|
||||
|
@ -583,6 +583,10 @@ const fixtures = {
|
||||
for (const event of DataGenerator.forKnex.members_created_events) {
|
||||
await models.MemberCreatedEvent.add(event);
|
||||
}
|
||||
}).then(async function () {
|
||||
for (const event of DataGenerator.forKnex.members_subscription_created_events) {
|
||||
await models.SubscriptionCreatedEvent.add(event);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -1602,6 +1602,18 @@ DataGenerator.forKnex = (function () {
|
||||
createBasic(DataGenerator.Content.members_stripe_customers_subscriptions[2])
|
||||
];
|
||||
|
||||
const members_subscription_created_events = stripe_customer_subscriptions.map((subscription, index) => {
|
||||
return {
|
||||
id: ObjectId().toHexString(),
|
||||
member_id: members[index].id,
|
||||
subscription_id: subscription.id,
|
||||
source: 'system',
|
||||
attribution_type: 'post',
|
||||
attribution_id: DataGenerator.Content.posts[index % 3].id,
|
||||
attribution_url: '/' + DataGenerator.Content.posts[index % 3].slug
|
||||
};
|
||||
});
|
||||
|
||||
const members_paid_subscription_events = [
|
||||
createBasic(DataGenerator.Content.members_paid_subscription_events[0]),
|
||||
createBasic(DataGenerator.Content.members_paid_subscription_events[1]),
|
||||
@ -1684,7 +1696,8 @@ DataGenerator.forKnex = (function () {
|
||||
comments,
|
||||
|
||||
members_paid_subscription_events,
|
||||
members_created_events
|
||||
members_created_events,
|
||||
members_subscription_created_events
|
||||
};
|
||||
}());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user