Skip to content

Commit

Permalink
patch query
Browse files Browse the repository at this point in the history
  • Loading branch information
hijiki51 committed Nov 12, 2023
1 parent e11b480 commit d0cdae4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM node:18-bookworm-slim AS builder
ENV GHOST_VERSION 5.54.0
ENV GHOST_VERSION 5.54.4
ENV NODE_ENV development

RUN apt-get update && apt-get install -y git tar git-filter-repo
Expand Down
2 changes: 1 addition & 1 deletion docker/DockerfileDockerize
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM node:18-bookworm-slim AS builder
ENV GHOST_VERSION 5.54.0
ENV GHOST_VERSION 5.54.4
ENV NODE_ENV development

RUN apt-get update && apt-get install -y git tar git-filter-repo
Expand Down
21 changes: 10 additions & 11 deletions ghost/core/core/server/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -1398,15 +1398,15 @@ Post = ghostBookshelf.Model.extend({
modelOrCollection.query('columns', 'posts.*', (qb) => {
qb.count('members_created_events.id')
.from('members_created_events')
.whereRaw('posts.id = members_created_events.attribution_id')
.whereRaw('`posts`.id = members_created_events.attribution_id')
.as('count__signups');
});
},
paid_conversions(modelOrCollection) {
modelOrCollection.query('columns', 'posts.*', (qb) => {
qb.count('members_subscription_created_events.id')
.from('members_subscription_created_events')
.whereRaw('posts.id = members_subscription_created_events.attribution_id')
.whereRaw('`posts`.id = members_subscription_created_events.attribution_id')
.as('count__paid_conversions');
});
},
Expand All @@ -1418,15 +1418,14 @@ Post = ghostBookshelf.Model.extend({
qb.count('*')
.from('k')
.with('k', (q) => {
q.select('member_id')
q.select('member_id','attribution_id')
.from('members_subscription_created_events')
.whereRaw('posts.id = members_subscription_created_events.attribution_id')
.union(function () {
this.select('member_id')
.from('members_created_events')
.whereRaw('posts.id = members_created_events.attribution_id');
this.select('member_id','attribution_id')
.from('members_created_events');
});
})
.whereRaw('`k`.attribution_id = `posts`.id')
.as('count__conversions');
});
},
Expand All @@ -1435,31 +1434,31 @@ Post = ghostBookshelf.Model.extend({
qb.countDistinct('members_click_events.member_id')
.from('members_click_events')
.join('redirects', 'members_click_events.redirect_id', 'redirects.id')
.whereRaw('posts.id = redirects.post_id')
.whereRaw('`posts`.id = redirects.post_id')
.as('count__clicks');
});
},
sentiment(modelOrCollection) {
modelOrCollection.query('columns', 'posts.*', (qb) => {
qb.select(qb.client.raw('COALESCE(ROUND(AVG(score) * 100), 0)'))
.from('members_feedback')
.whereRaw('posts.id = members_feedback.post_id')
.whereRaw('`posts`.id = members_feedback.post_id')
.as('count__sentiment');
});
},
negative_feedback(modelOrCollection) {
modelOrCollection.query('columns', 'posts.*', (qb) => {
qb.count('*')
.from('members_feedback')
.whereRaw('posts.id = members_feedback.post_id AND members_feedback.score = 0')
.whereRaw('`posts`.id = members_feedback.post_id AND members_feedback.score = 0')
.as('count__negative_feedback');
});
},
positive_feedback(modelOrCollection) {
modelOrCollection.query('columns', 'posts.*', (qb) => {
qb.sum('score')
.from('members_feedback')
.whereRaw('posts.id = members_feedback.post_id')
.whereRaw('`posts`.id = members_feedback.post_id')
.as('count__positive_feedback');
});
}
Expand Down

0 comments on commit d0cdae4

Please sign in to comment.