INSERT INTO config (config_key, config_value, value_type) VALUES
('send_info', '0', 'boolean'),
('info_sent', '0', 'number'),
('daemon_port', '58846', 'number'),
('allow_remote', '0', 'boolean'),
('pre_allocate_storage', '1', 'boolean'),
('download_location', '/data/deluge', 'string'),
('listen_ports', '[6881,6891]', 'json'),
('listen_interface', '', 'string'),
('outgoing_interface', 'tun0', 'string'),
('random_port', '1', 'boolean'),
('listen_random_port', '53461', 'number'),
('listen_use_sys_port', '0', 'boolean'),
('listen_reuse_port', '1', 'boolean'),
('outgoing_ports', '[0,0]', 'json'),
('random_outgoing_ports', '1', 'boolean'),
('copy_torrent_file', '0', 'boolean'),
('del_copy_torrent_file', '0', 'boolean'),
('torrentfiles_location', '/root/Downloads', 'string'),
('plugins_location', '/root/.config/deluge/plugins', 'string'),
('prioritize_first_last_pieces', '0', 'boolean'),
('sequential_download', '0', 'boolean'),
('dht', '1', 'boolean'),
('upnp', '1', 'boolean'),
('natpmp', '1', 'boolean'),
('utpex', '1', 'boolean'),
('lsd', '1', 'boolean'),
('enc_in_policy', '1', 'number'),
('enc_out_policy', '1', 'number'),
('enc_level', '2', 'number'),
('max_connections_global', '200', 'number'),
('max_upload_speed', '-1', 'number'),
('max_download_speed', '-1', 'number'),
('max_upload_slots_global', '4', 'number'),
('max_half_open_connections', '50', 'number'),
('max_connections_per_second', '20', 'number'),
('ignore_limits_on_local_network', '1', 'boolean'),
('max_connections_per_torrent', '-1', 'number'),
('max_upload_slots_per_torrent', '-1', 'number'),
('max_upload_speed_per_torrent', '-1', 'number'),
('max_download_speed_per_torrent', '-1', 'number'),
('enabled_plugins', '["Label"]', 'json'),
('add_paused', '0', 'boolean'),
('max_active_seeding', '5', 'number'),
('max_active_downloading', '3', 'number'),
('max_active_limit', '8', 'number'),
('dont_count_slow_torrents', '0', 'boolean'),
('queue_new_to_top', '0', 'boolean'),
('stop_seed_at_ratio', '0', 'boolean'),
('remove_seed_at_ratio', '0', 'boolean'),
('stop_seed_ratio', '2', 'number'),
('share_ratio_limit', '2', 'number'),
('seed_time_ratio_limit', '7', 'number'),
('seed_time_limit', '180', 'number'),
('auto_managed', '1', 'boolean'),
('move_completed', '0', 'boolean'),
('move_completed_path', '/root/Downloads', 'string'),
('move_completed_paths_list', '[]', 'json'),
('download_location_paths_list', '[]', 'json'),
('path_chooser_show_chooser_button_on_localhost', '1', 'boolean'),
('path_chooser_auto_complete_enabled', '1', 'boolean'),
('path_chooser_accelerator_string', 'Tab', 'string'),
('path_chooser_max_popup_rows', '20', 'number'),
('path_chooser_show_hidden_files', '0', 'boolean'),
('new_release_check', '0', 'boolean'),
('proxy', '{"anonymous_mode":false,"force_proxy":false,"hostname":"","password":"","port":8080,"proxy_hostnames":true,"proxy_peer_connections":true,"proxy_tracker_connections":true,"type":0,"username":""}', 'json'),
('peer_tos', '0x00', 'string'),
('rate_limit_ip_overhead', '1', 'boolean'),
('geoip_db_location', '/usr/share/GeoIP/GeoIP.dat', 'string'),
('cache_size', '512', 'number'),
('cache_expiry', '60', 'number'),
('auto_manage_prefer_seeds', '0', 'boolean'),
('shared', '0', 'boolean'),
('super_seeding', '0', 'boolean')
ON DUPLICATE KEY UPDATE config_value = VALUES(config_value), value_type = VALUES(value_type);

INSERT INTO torrents (
  torrent_id, name, state, progress, download_payload_rate, upload_payload_rate, ratio,
  eta, total_size, total_wanted, save_path, tracker_host, tracker_status,
  num_seeds, total_seeds, num_peers, total_peers, max_download_speed,
  max_upload_speed, max_connections, max_upload_slots, is_auto_managed,
  stop_at_ratio, stop_ratio, remove_at_ratio, move_completed, move_completed_path,
  prioritize_first_last_pieces, queue_position, is_finished, source_kind, source_value,
  time_added, updated_at
) VALUES
('4d3c314a66e520cb733dfae8f62d94f46ddd5788', 'Mission.Impossible.The.Final.Reckoning.2025.MULTi.TRUEFRENCH.VF2.HDR.DV.2160p.WEB.H265-SUPPLY.mkv', 'Seeding', 100.00, 0, 0, 0.001193, 0, 33386316432, 33386316432, '/data/deluge', 'opentrackr.org', 'Working', 0, 50, 5, 20, -1, -1, -1, -1, 1, 0, 2.0, 0, 0, '', 0, -1, 1, 'url', 'https://example.test/mission-impossible.torrent', NOW() - INTERVAL 10 DAY, NOW()),
('2e8e44068b254814ea1a7d4969a9af1d78e0f51f', 'ubuntu-22.04.5-desktop-amd64.iso', 'Downloading', 21.83, 12836444, 6832, 0.000206, 290, 4762707968, 4762707968, '/data/deluge', 'ubuntu.com', 'Announce OK', 82, 180, 19, 40, -1, -1, -1, -1, 1, 0, 2.0, 0, 0, '', 0, 0, 0, 'url', 'https://releases.ubuntu.com/22.04/ubuntu-22.04.5-desktop-amd64.iso.torrent', NOW() - INTERVAL 1 HOUR, NOW()),
('3333333333333333333333333333333333333333', 'Big Buck Bunny Remastered', 'Paused', 18.25, 0, 0, 0.030000, -1, 4294967296, 4294967296, '/data/deluge', 'tracker.example.org', 'Paused', 7, 45, 3, 12, 5000, 800, 120, 4, 1, 0, 2.0, 0, 0, '', 1, 1, 0, 'magnet', 'magnet:?xt=urn:btih:BIGBUCKBUNNYMOCK', NOW() - INTERVAL 1 DAY, NOW()),
('4444444444444444444444444444444444444444', 'LibreOffice SDK Archive', 'Queued', 0.00, 0, 0, 0.000000, -1, 734003200, 734003200, '/data/deluge', 'tracker.documentfoundation.org', 'Queued', 12, 51, 0, 8, -1, -1, -1, -1, 1, 0, 2.0, 0, 0, '', 0, 2, 0, 'url', 'https://download.documentfoundation.org/mock/libreoffice-sdk.torrent', NOW() - INTERVAL 3 HOUR, NOW()),
('5555555555555555555555555555555555555555', 'Home Assistant Backup 2026-03-10', 'Downloading', 91.10, 2540000, 122000, 0.170000, 60, 17179869184, 17179869184, '/data/deluge', 'tracker.backup.local', 'Announce OK', 18, 80, 11, 27, -1, -1, -1, -1, 1, 0, 2.0, 0, 1, '/data/deluge/completed', 0, 3, 0, 'url', 'https://example.test/ha-backup.torrent', NOW() - INTERVAL 12 HOUR, NOW())
ON DUPLICATE KEY UPDATE updated_at = VALUES(updated_at);

INSERT INTO torrent_files (torrent_id, file_index, file_path, file_size, progress, priority) VALUES
('4d3c314a66e520cb733dfae8f62d94f46ddd5788', 0, 'Mission.Impossible.The.Final.Reckoning.2025.MULTi.TRUEFRENCH.VF2.HDR.DV.2160p.WEB.H265-SUPPLY.mkv', 33386316432, 100.00, 1),
('2e8e44068b254814ea1a7d4969a9af1d78e0f51f', 0, 'ubuntu-22.04.5-desktop-amd64.iso', 4762707968, 21.83, 1),
('3333333333333333333333333333333333333333', 0, 'Big Buck Bunny Remastered/BigBuckBunny.mkv', 3221225472, 18.25, 1),
('3333333333333333333333333333333333333333', 1, 'Big Buck Bunny Remastered/poster.jpg', 5242880, 100.00, 0),
('4444444444444444444444444444444444444444', 0, 'LibreOffice SDK Archive/libreoffice-sdk.tar.xz', 734003200, 0.00, 1),
('5555555555555555555555555555555555555555', 0, 'Home Assistant Backup 2026-03-10/full-backup.tar', 17179869184, 91.10, 1)
ON DUPLICATE KEY UPDATE progress = VALUES(progress), priority = VALUES(priority);

INSERT INTO torrent_trackers (torrent_id, tracker_tier, tracker_url, status, msg) VALUES
('4d3c314a66e520cb733dfae8f62d94f46ddd5788', 0, 'udp://tracker.opentrackr.org:1337/announce', 2, 'Working'),
('2e8e44068b254814ea1a7d4969a9af1d78e0f51f', 0, 'https://tracker.ubuntu.com/announce', 2, 'Working'),
('3333333333333333333333333333333333333333', 0, 'udp://tracker.torrent.eu.org:451/announce', 1, 'No response yet'),
('4444444444444444444444444444444444444444', 0, 'https://tracker.documentfoundation.org/announce', 1, 'Queued'),
('5555555555555555555555555555555555555555', 0, 'udp://tracker.opentrackr.org:1337/announce', 2, 'Working');

INSERT INTO torrent_peers (torrent_id, peer_ip, client_name, progress, down_speed, up_speed, country) VALUES
('4d3c314a66e520cb733dfae8f62d94f46ddd5788', '91.134.12.44', 'qBittorrent 5.0', 100.00, 0, 240000, 'FR'),
('2e8e44068b254814ea1a7d4969a9af1d78e0f51f', '178.62.98.16', 'Transmission 4.0', 71.20, 1250000, 120000, 'NL'),
('2e8e44068b254814ea1a7d4969a9af1d78e0f51f', '85.214.132.11', 'Deluge 2.1', 82.40, 2450000, 180000, 'DE'),
('3333333333333333333333333333333333333333', '203.0.113.20', 'libtorrent 2.0', 21.10, 340000, 35000, 'US'),
('5555555555555555555555555555555555555555', '198.51.100.72', 'qBittorrent 4.6', 95.30, 940000, 95000, 'CA');

INSERT INTO events (event_type, payload_json, created_at) VALUES
('SessionStartedEvent', JSON_OBJECT('host', 'mock-deluge-host'), NOW() - INTERVAL 1 HOUR),
('TorrentAddedEvent', JSON_OBJECT('torrent_id', '5555555555555555555555555555555555555555'), NOW() - INTERVAL 40 MINUTE),
('TorrentFinishedEvent', JSON_OBJECT('torrent_id', '4d3c314a66e520cb733dfae8f62d94f46ddd5788'), NOW() - INTERVAL 10 MINUTE);
