-
Notifications
You must be signed in to change notification settings - Fork 122
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
Bugfix - PostgreSQL Subscriber Growth Chart #15
Conversation
HI @MaizerGomes - thanks for the PR! We actually need a slightly different implementation to handle this. If you look at how we handle Campaigns (https://github.com/mettle/sendportal-core/tree/master/src/Repositories/Campaigns), you'll see that we have a Base repository, and then separate repositories for Mysql and Postgres. We should do the same thing for Subscribers in this case. Do you want to have a try again? |
…greSQL fix)" This reverts commit 1ffe7fd.
Thank you for your reply. I still hadn't gone through the rest of the code and just wanted something quick just so I could try your app. You're right, this approach is way cleaner and maintainable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
Looks great @MaizerGomes, thanks for the PR! 🎉 |
After installing using postgresql database, an error showed up informing that "date_format function doesn't exist".
The problem is in this file:
vendor/mettle/sendportal-core/src/Repositories/SubscriberTenantRepository.php
From line 152 to 166:
` $runningTotal = DB::table('subscribers')
->selectRaw("date_format(created_at, '%d-%m-%Y') AS date, count(*) as total")
->where('workspace_id', $workspaceId)
->where('created_at', '>=', $period->getStartDate())
->where('created_at', '<=', $period->getEndDate())
->groupBy('date')
->get();
On postgresql you can use the function "to_char" instead of "date_format" since it doesn't exist:
->selectRaw("to_char(created_at, 'dd-mm-yyyy') AS date
Issue referenced here