changes
This commit is contained in:
47
fusion_tasks/graphify-out/calendar_check.sql
Normal file
47
fusion_tasks/graphify-out/calendar_check.sql
Normal file
@@ -0,0 +1,47 @@
|
||||
\pset border 2
|
||||
\pset format aligned
|
||||
|
||||
\echo '== A. Calendar event coverage on active tasks (last 30 days + future) =='
|
||||
SELECT
|
||||
COALESCE(NULLIF(x_fc_sync_source,''), '<local>') AS source,
|
||||
status,
|
||||
COUNT(*) AS task_count,
|
||||
COUNT(calendar_event_id) AS with_calendar_event,
|
||||
COUNT(*) - COUNT(calendar_event_id) AS missing
|
||||
FROM fusion_technician_task
|
||||
WHERE active = TRUE
|
||||
AND scheduled_date >= CURRENT_DATE - 30
|
||||
AND technician_id IS NOT NULL
|
||||
GROUP BY 1, 2
|
||||
ORDER BY 1, 2;
|
||||
|
||||
\echo ''
|
||||
\echo '== B. Spot-check: recent tasks WITHOUT calendar_event_id =='
|
||||
SELECT id, name, technician_id, x_fc_sync_source, status, scheduled_date, datetime_start, datetime_end
|
||||
FROM fusion_technician_task
|
||||
WHERE active = TRUE
|
||||
AND scheduled_date >= CURRENT_DATE - 7
|
||||
AND technician_id IS NOT NULL
|
||||
AND calendar_event_id IS NULL
|
||||
AND status NOT IN ('cancelled', 'completed')
|
||||
ORDER BY scheduled_date DESC, id DESC
|
||||
LIMIT 20;
|
||||
|
||||
\echo ''
|
||||
\echo '== C. Sample of linked calendar.event records (most recent 5) =='
|
||||
SELECT t.id AS task_id, t.name AS task_name,
|
||||
ce.id AS event_id, ce.name AS event_name,
|
||||
ce.start AS ev_start, ce.stop AS ev_stop,
|
||||
t.x_fc_sync_source AS source
|
||||
FROM fusion_technician_task t
|
||||
JOIN calendar_event ce ON ce.id = t.calendar_event_id
|
||||
WHERE t.active = TRUE
|
||||
ORDER BY t.write_date DESC
|
||||
LIMIT 5;
|
||||
|
||||
\echo ''
|
||||
\echo '== D. Are external calendar sync modules installed? =='
|
||||
SELECT name, state, latest_version FROM ir_module_module
|
||||
WHERE name IN ('google_calendar', 'microsoft_calendar', 'calendar', 'mail')
|
||||
OR name LIKE '%calendar%'
|
||||
ORDER BY name;
|
||||
42
fusion_tasks/graphify-out/calendar_check2.sql
Normal file
42
fusion_tasks/graphify-out/calendar_check2.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
\pset border 2
|
||||
\pset format aligned
|
||||
|
||||
\echo '== E. Are calendar events linked to the tech as organizer + attendee? =='
|
||||
SELECT t.id AS task_id, t.name AS task_name,
|
||||
ce.user_id AS event_organizer_uid,
|
||||
u_org.login AS organizer_login,
|
||||
u_tech.login AS task_tech_login,
|
||||
(SELECT COUNT(*) FROM calendar_event_res_partner_rel
|
||||
WHERE calendar_event_id = ce.id) AS attendee_count,
|
||||
(SELECT COUNT(*) FROM calendar_event_res_partner_rel cer
|
||||
JOIN res_users u2 ON u2.partner_id = cer.res_partner_id
|
||||
WHERE cer.calendar_event_id = ce.id AND u2.id = t.technician_id) AS tech_is_attendee
|
||||
FROM fusion_technician_task t
|
||||
JOIN calendar_event ce ON ce.id = t.calendar_event_id
|
||||
JOIN res_users u_tech ON u_tech.id = t.technician_id
|
||||
LEFT JOIN res_users u_org ON u_org.id = ce.user_id
|
||||
WHERE t.active = TRUE
|
||||
AND t.scheduled_date >= CURRENT_DATE - 3
|
||||
AND t.scheduled_date <= CURRENT_DATE + 7
|
||||
ORDER BY t.scheduled_date, t.id
|
||||
LIMIT 12;
|
||||
|
||||
\echo ''
|
||||
\echo '== F. Microsoft Calendar OAuth: how many users have it connected? =='
|
||||
SELECT
|
||||
COUNT(*) FILTER (WHERE microsoft_calendar_token IS NOT NULL AND microsoft_calendar_token <> '') AS users_with_ms_token,
|
||||
COUNT(*) FILTER (WHERE x_fc_is_field_staff = TRUE
|
||||
AND microsoft_calendar_token IS NOT NULL
|
||||
AND microsoft_calendar_token <> '') AS field_staff_with_ms_token,
|
||||
COUNT(*) FILTER (WHERE x_fc_is_field_staff = TRUE AND active = TRUE) AS active_field_staff
|
||||
FROM res_users;
|
||||
|
||||
\echo ''
|
||||
\echo '== G. Per-tech: connected to MS calendar? =='
|
||||
SELECT u.login, u.x_fc_tech_sync_id,
|
||||
(microsoft_calendar_token IS NOT NULL AND microsoft_calendar_token <> '') AS ms_connected,
|
||||
(microsoft_calendar_sync_token IS NOT NULL AND microsoft_calendar_sync_token <> '') AS ms_sync_token,
|
||||
microsoft_calendar_account_id
|
||||
FROM res_users u
|
||||
WHERE u.x_fc_is_field_staff = TRUE AND u.active = TRUE
|
||||
ORDER BY u.login;
|
||||
25
fusion_tasks/graphify-out/mobility_sync_fix.py
Normal file
25
fusion_tasks/graphify-out/mobility_sync_fix.py
Normal file
@@ -0,0 +1,25 @@
|
||||
print('=== BEFORE ===')
|
||||
for uid in (32, 27):
|
||||
u = env['res.users'].browse(uid)
|
||||
print(f" uid={uid} login={u.login} active={u.active} "
|
||||
f"field_staff={u.x_fc_is_field_staff} sync_id={u.x_fc_tech_sync_id!r}")
|
||||
|
||||
try:
|
||||
env['res.users'].browse(32).x_fc_tech_sync_id = 'simranjeet'
|
||||
env['res.users'].browse(27).write({
|
||||
'x_fc_is_field_staff': True,
|
||||
'x_fc_tech_sync_id': 'hk',
|
||||
})
|
||||
env.cr.commit()
|
||||
print('Commit OK')
|
||||
except Exception as e:
|
||||
env.cr.rollback()
|
||||
print(f'FAILED: {type(e).__name__}: {e}')
|
||||
raise
|
||||
|
||||
print('=== AFTER ===')
|
||||
for uid in (32, 27):
|
||||
u = env['res.users'].browse(uid)
|
||||
print(f" uid={uid} login={u.login} active={u.active} "
|
||||
f"field_staff={u.x_fc_is_field_staff} sync_id={u.x_fc_tech_sync_id!r}")
|
||||
print('DONE')
|
||||
62
fusion_tasks/graphify-out/sync_evidence.sql
Normal file
62
fusion_tasks/graphify-out/sync_evidence.sql
Normal file
@@ -0,0 +1,62 @@
|
||||
\pset border 2
|
||||
\pset format aligned
|
||||
|
||||
\echo '== 1. Local instance ID =='
|
||||
SELECT key, value
|
||||
FROM ir_config_parameter
|
||||
WHERE key = 'fusion_claims.sync_instance_id';
|
||||
|
||||
\echo ''
|
||||
\echo '== 2. Remote sync configs (other instances we sync with) =='
|
||||
SELECT id, name, instance_id, url, database, username, active,
|
||||
last_sync, LEFT(COALESCE(last_sync_error,''), 200) AS last_sync_error
|
||||
FROM fusion_task_sync_config;
|
||||
|
||||
\echo ''
|
||||
\echo '== 3. Field technicians and sync IDs =='
|
||||
SELECT u.id, u.login, p.name AS partner_name,
|
||||
u.x_fc_is_field_staff, u.x_fc_tech_sync_id, u.active
|
||||
FROM res_users u
|
||||
JOIN res_partner p ON p.id = u.partner_id
|
||||
WHERE u.x_fc_is_field_staff = TRUE
|
||||
OR (u.x_fc_tech_sync_id IS NOT NULL AND u.x_fc_tech_sync_id <> '')
|
||||
ORDER BY u.active DESC, u.login;
|
||||
|
||||
\echo ''
|
||||
\echo '== 4. Recent task flow (last 7 days) =='
|
||||
SELECT
|
||||
COALESCE(NULLIF(x_fc_sync_source,''), '<local>') AS source,
|
||||
status,
|
||||
COUNT(*) AS cnt,
|
||||
MIN(scheduled_date) AS min_date,
|
||||
MAX(scheduled_date) AS max_date
|
||||
FROM fusion_technician_task
|
||||
WHERE create_date > NOW() - INTERVAL '7 days'
|
||||
GROUP BY 1, 2
|
||||
ORDER BY 1, 2;
|
||||
|
||||
\echo ''
|
||||
\echo '== 5. Cron jobs for Fusion Tasks =='
|
||||
SELECT
|
||||
c.id,
|
||||
REPLACE(REPLACE(c.cron_name, 'Fusion Tasks:', ''), ' ', ' ') AS job,
|
||||
c.active,
|
||||
c.interval_number || ' ' || c.interval_type AS every,
|
||||
c.lastcall, c.nextcall
|
||||
FROM ir_cron c
|
||||
WHERE c.cron_name LIKE 'Fusion Tasks%'
|
||||
ORDER BY c.cron_name;
|
||||
|
||||
\echo ''
|
||||
\echo '== 6. Tasks scheduled today/tomorrow by tech =='
|
||||
SELECT
|
||||
u.login AS tech_login,
|
||||
u.x_fc_tech_sync_id AS sync_id,
|
||||
COALESCE(NULLIF(t.x_fc_sync_source,''), '<local>') AS source,
|
||||
COUNT(*) AS cnt
|
||||
FROM fusion_technician_task t
|
||||
JOIN res_users u ON u.id = t.technician_id
|
||||
WHERE t.scheduled_date BETWEEN CURRENT_DATE - 1 AND CURRENT_DATE + 7
|
||||
AND t.active = TRUE
|
||||
GROUP BY 1,2,3
|
||||
ORDER BY 1,3;
|
||||
19
fusion_tasks/graphify-out/sync_evidence_2.sql
Normal file
19
fusion_tasks/graphify-out/sync_evidence_2.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
\pset border 2
|
||||
\pset format aligned
|
||||
|
||||
\echo '== Garry vs Gurpreet on westin =='
|
||||
SELECT u.id, u.login, u.active, u.share, u.create_date, u.write_date,
|
||||
u.x_fc_tech_sync_id,
|
||||
(SELECT COUNT(*) FROM fusion_technician_task t WHERE t.technician_id = u.id) AS total_tasks,
|
||||
(SELECT MAX(create_date) FROM fusion_technician_task t WHERE t.technician_id = u.id) AS last_task_create,
|
||||
(SELECT COUNT(*) FROM mail_message m WHERE m.author_id = u.partner_id) AS messages
|
||||
FROM res_users u
|
||||
WHERE u.id IN (2, 85);
|
||||
|
||||
\echo ''
|
||||
\echo '== HK detail on westin =='
|
||||
SELECT u.id, u.login, p.name AS partner_name, p.email, p.phone, p.mobile,
|
||||
u.x_fc_is_field_staff, u.x_fc_tech_sync_id, u.active
|
||||
FROM res_users u
|
||||
JOIN res_partner p ON p.id = u.partner_id
|
||||
WHERE u.id = 39;
|
||||
31
fusion_tasks/graphify-out/sync_verify.sql
Normal file
31
fusion_tasks/graphify-out/sync_verify.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
\pset border 2
|
||||
\pset format aligned
|
||||
|
||||
\echo '== A. All field staff and sync IDs (live) =='
|
||||
SELECT u.id, u.login, p.name, u.x_fc_is_field_staff, u.x_fc_tech_sync_id, u.active
|
||||
FROM res_users u JOIN res_partner p ON p.id = u.partner_id
|
||||
WHERE u.x_fc_is_field_staff = TRUE
|
||||
OR (u.x_fc_tech_sync_id IS NOT NULL AND u.x_fc_tech_sync_id <> '')
|
||||
ORDER BY u.active DESC, u.login;
|
||||
|
||||
\echo ''
|
||||
\echo '== B. Last pull cron run + sync config status =='
|
||||
SELECT
|
||||
(SELECT to_char(lastcall, 'YYYY-MM-DD HH24:MI:SS') FROM ir_cron WHERE cron_name LIKE 'Fusion Tasks: Sync Remote Tasks (Pull)') AS last_pull_cron,
|
||||
(SELECT to_char(last_sync, 'YYYY-MM-DD HH24:MI:SS') FROM fusion_task_sync_config LIMIT 1) AS last_sync,
|
||||
(SELECT LEFT(COALESCE(last_sync_error,'(none)'),120) FROM fusion_task_sync_config LIMIT 1) AS last_sync_error,
|
||||
to_char(NOW(), 'YYYY-MM-DD HH24:MI:SS') AS now;
|
||||
|
||||
\echo ''
|
||||
\echo '== C. Tasks by tech in next 7 days (target: simranjeet + hk shadows now appear) =='
|
||||
SELECT
|
||||
u.login AS tech_login,
|
||||
u.x_fc_tech_sync_id AS sync_id,
|
||||
COALESCE(NULLIF(t.x_fc_sync_source,''), '<local>') AS source,
|
||||
COUNT(*) AS cnt
|
||||
FROM fusion_technician_task t
|
||||
JOIN res_users u ON u.id = t.technician_id
|
||||
WHERE t.scheduled_date BETWEEN CURRENT_DATE - 1 AND CURRENT_DATE + 7
|
||||
AND t.active = TRUE
|
||||
GROUP BY 1,2,3
|
||||
ORDER BY 1,3;
|
||||
16
fusion_tasks/graphify-out/westin_sync_fix.py
Normal file
16
fusion_tasks/graphify-out/westin_sync_fix.py
Normal file
@@ -0,0 +1,16 @@
|
||||
print('=== BEFORE ===')
|
||||
for uid in (85, 100, 39):
|
||||
u = env['res.users'].browse(uid)
|
||||
print(f" uid={uid} login={u.login} active={u.active} sync_id={u.x_fc_tech_sync_id!r}")
|
||||
|
||||
env['res.users'].browse(85).active = False
|
||||
env['res.users'].browse(100).x_fc_tech_sync_id = 'simranjeet'
|
||||
env['res.users'].browse(39).x_fc_tech_sync_id = 'hk'
|
||||
|
||||
env.cr.commit()
|
||||
|
||||
print('=== AFTER ===')
|
||||
for uid in (85, 100, 39):
|
||||
u = env['res.users'].with_context(active_test=False).browse(uid)
|
||||
print(f" uid={uid} login={u.login} active={u.active} sync_id={u.x_fc_tech_sync_id!r}")
|
||||
print('DONE')
|
||||
Reference in New Issue
Block a user