public function removeDeletedEvents($ids)
    {
        global $wpdb;
        $table = $wpdb->prefix . "integrate_occasions";
        // Get all locally stored events
        $localEvents = $wpdb->get_results("SELECT event_id FROM {$table} GROUP BY event_id", ARRAY_N);
        $localEvents = array_map(function($id) {
            return $id[0];
        }, $localEvents);
        // Collect local IDs of the API events
        $apiEvents = array_map(function($id) {
            $post = get_posts(array(
                'post_type' => 'event',
                'post_status' => array('publish', 'draft'),
                'meta_key' => '_event_manager_id',
                'meta_value' => $id,
                'posts_per_page' => 1
            ));
            return $post[0]->ID ?? null;
        }, array_unique($ids));
        $apiEvents = array_filter($apiEvents);
        // Collect events that is stored locally but is missing in the API
        $diffEvents = array_diff($localEvents, $apiEvents);
        // Loop through the diff and delete its occasions
        if (!empty($diffEvents)) {
            foreach ($diffEvents as $event) {
                $wpdb->delete($table, array('event_id' => $event));
            }
        }
    }