Skip to content

Instantly share code, notes, and snippets.

View heathdutton's full-sized avatar
🕴️
Headlines are unsanitized input. Attention is prod.

Heath Dutton🕴️ heathdutton

🕴️
Headlines are unsanitized input. Attention is prod.
View GitHub Profile
@heathdutton
heathdutton / unused_mautic_segments.sql
Created June 21, 2019 15:55
Find unused segments in Mautic that could be churning uselessly.
-- Find unused segments that can be unpublished to save processing time.
SELECT l.id, l.created_by_user, l.name, IF (l.date_modified IS NULL, l.date_added, l.date_modified) AS date_modified,
(SELECT COUNT(*) FROM lead_lists_leads WHERE leadlist_id = l.id) AS lead_count
FROM lead_lists l
WHERE
l.is_published = 1
AND l.id NOT IN (
-- Find segments in use.
SELECT l.id
FROM lead_lists l
@heathdutton
heathdutton / delete_default_widgets.sql
Created March 18, 2019 15:19
Delete default widgets in mautic core so that they fall back to default.json contents
DELETE FROM widgets WHERE type IN ('created.leads.in.time','page.hits.in.time','submissions.in.time','recent.activity','upcoming.emails','created.leads.in.time','map.of.leads','top.lists','page.hits.in.time','emails.in.time','unique.vs.returning.leads','ignored.vs.read.emails','anonymous.vs.identified.leads','dwell.times','recent.activity','upcoming.emails');
@heathdutton
heathdutton / mautic-container.sh
Created December 13, 2018 16:55
Mautic 2.15.0 Container public services
sudo -u webapp bash -c "DEBUG=1 /var/app/current/mautic/app/console debug:container --env=dev"
Symfony Container Public Services
=================================
------------------------------------------------------------------------------------------------------ -----------------------------------------------------------------------------------------------
Service ID Class name
------------------------------------------------------------------------------------------------------ -----------------------------------------------------------------------------------------------
annotation_reader Doctrine\Common\Annotations\CachedReader
assets.context Symfony\Component\Asset\Context\RequestStackContext
@heathdutton
heathdutton / mautic-routes.sh
Last active December 13, 2018 16:55
Mautic 2.15.0 Routes
sudo -u webapp bash -c "DEBUG=1 /var/app/current/mautic/app/console debug:router"
------------------------------------------- ---------------- -------- ------ -------------------------------------------------------------------------------------------------
Name Method Scheme Host Path
------------------------------------------- ---------------- -------- ------ -------------------------------------------------------------------------------------------------
mautic_js ANY https ANY /mtc.js
mautic_base_index ANY https ANY /
mautic_secure_root ANY https ANY /s
mautic_secure_root_slash ANY https ANY /s/
mautic_remove_trailing_slash GET https ANY /{url}
@heathdutton
heathdutton / notification_cleanup.sql
Created November 15, 2018 02:09
Delete ancient notifications from Mautic.
DELETE FROM notifications WHERE date_added < DATE_SUB(NOW(), INTERVAL 7 DAY);
@heathdutton
heathdutton / mautic-campaign-delays-lite.sql
Last active February 25, 2019 21:54
List all Mautic campaign delays
-- All mautic campaign delays merged. Two queries (the first is important). Takes under 10s.
-- Depends on the PR of soft-deleted campaign events.
SET @@group_concat_max_len = 10000000000000;
SELECT *
FROM (
SELECT NULL as campaign_id,
NULL as campaign_name,
NULL as event_id,
NULL as event_name,
NULL as lead_count,
@heathdutton
heathdutton / mautic-campaign-delays.sql
Last active November 2, 2018 20:50
Show all Mautic campaign delays in one table.
-- All mautic delays merged. Two queries (the first is important).
SET @@group_concat_max_len = 10000000000000;
SELECT *
FROM (
SELECT NULL as campaign_id,
NULL as campaign_name,
NULL as event_id,
NULL as event_name,
NULL as lead_count,
NULL as type,
@heathdutton
heathdutton / campaigns_unpublished_by_category.sql
Last active October 5, 2018 14:39
Find unpublished categories in Mautic that have published campaigns under them. Because these categories are unpublished all campaigns under them will be paused.
SELECT cat.id as category_id, cat.title as category_name, COUNT(camp.id) as campaigns
FROM campaigns camp
LEFT JOIN categories cat
ON camp.category_id = cat.id
WHERE
cat.is_published = 0
AND camp.is_published = 1
GROUP BY cat.id;
@heathdutton
heathdutton / cf_settings_set.sh
Created September 28, 2018 19:55
Script I use to set typical Cloudflare settings.
#! /bin/bash
cf_user=xxxxxxxxx
cf_token=xxxxxxxxx
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
if [ -z $1 ]
@heathdutton
heathdutton / permissions.sh
Last active January 26, 2019 00:13
Permissions for Mautic
cd /home/clientsiwanta/public_html/mautic/
find . -type d -exec sudo chmod 755 {} \;
find . -type f -exec sudo chmod 644 {} \;
sudo chmod -R g+w app/cache/
sudo chmod -R g+w app/logs/
sudo chmod -R g+w app/config/
sudo chmod -R g+w media/files/
sudo chmod -R g+w media/images/
sudo chmod -R g+w translations/
sudo chown -R www-data:www-data .