<commit_before># models/purge_request.rb:
# A queue of URLs to purge
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/
#

class PurgeRequest < ActiveRecord::Base
    require 'open-uri'
    def self.purge_all
        for item in PurgeRequest.all()
            item.purge
        end
    end

    def purge
        config = MySociety::Config.load_default()
        varnish_url = config['VARNISH_HOST']
        result = quietly_try_to_purge(varnish_url, self.url)
        if result == "200"<commit_msg>Add a method to run the purge process in a continuous loop<commit_after># models/purge_request.rb:
# A queue of URLs to purge
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: <EMAIL>; WWW: http://www.mysociety.org/
#

class PurgeRequest < ActiveRecord::Base
    def self.purge_all
        done_something = false
        for item in PurgeRequest.all()
            item.purge
            done_something = true
        end
        return done_something
    end

    def self.purge_all_loop
        # Run purge_all in an endless loop, sleeping when there is nothing to do
        while true
            sleep_seconds = 1
            while !purge_all
                sleep sleep_seconds
                sleep_seconds *= 2
                sleep_seconds = 300 if sleep_seconds > 300
            end
        end
    end

    def purge
        config = MySociety::Config.load_default()
        varnish_url = config['VARNISH_HOST']
        result = quietly_try_to_purge(varnish_url, self.url)
        if result == "200"
{'fraction_non_alphanumeric': 0.07678018575851393, 'fraction_numerical': 0.013622291021671827, 'mean_word_length': 2.2515090543259557, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4410607', 'n_tokens_mistral': 516, 'n_tokens_neox': 467, 'n_words': 143}