<commit_before>CREATE OR REPLACE FUNCTION delete_project(_project_uid integer)
 RETURNS void AS $$

 BEGIN
    DELETE FROM projects WHERE project_uid = _project_uid;

    EXECUTE
    'DROP TABLE IF EXISTS ext_tables.project_' || _project_uid || '_plots_csv;'
    'DROP TABLE IF EXISTS ext_tables.project_' || _project_uid || '_plots_shp;'
    'DROP TABLE IF EXISTS ext_tables.project_' || _project_uid || '_samples_csv;'
    'DROP TABLE IF EXISTS ext_tables.project_' || _project_uid || '_samples_shp;';
 END

$$ LANGUAGE PLPGSQL;

CREATE OR REPLACE FUNCTION plots_missing_samples(_project_uid integer)
 RETURNS integer AS $$

    SELECT count(1)::int
    FROM projects p
    INNER JOIN plots pl
        ON pl.project_rid = project_uid
    LEFT JOIN samples s
        ON plot_uid = s.plot_rid
    WHERE project_uid = _project_uid
        AND sample_uid IS NULL

$$ LANGUAGE SQL;<commit_msg>update delete to leave project info<commit_after>CREATE OR REPLACE FUNCTION delete_project(_project_uid integer)
 RETURNS void AS $$

 BEGIN
    DELETE FROM plots
    WHERE plot_uid IN (
        SELECT plot_uid
        FROM projects
        INNER JOIN plots
            ON project_uid = project_rid
            AND project_uid = _project_uid);

    UPDATE projects SET availability='archived' WHERE project_uid = _project_uid;

    EXECUTE
    'DROP TABLE IF EXISTS ext_tables.project_' || _project_uid || '_plots_csv;'
    'DROP TABLE IF EXISTS ext_tables.project_' || _project_uid || '_plots_shp;'
    'DROP TABLE IF EXISTS ext_tables.project_' || _project_uid || '_samples_csv;'
    'DROP TABLE IF EXISTS ext_tables.project_' || _project_uid || '_samples_shp;';
 END

$$ LANGUAGE PLPGSQL;

CREATE OR REPLACE FUNCTION plots_missing_samples(_project_uid integer)
 RETURNS integer AS $$

    SELECT count(1)::int
    FROM projects p
    INNER JOIN plots pl
        ON pl.project_rid = project_uid
    LEFT JOIN samples s
        ON plot_uid = s.plot_rid
    WHERE project_uid = _project_uid
        AND sample_uid IS NULL

$$ LANGUAGE SQL;
{'fraction_non_alphanumeric': 0.07195662888122227, 'fraction_numerical': 0.0009857072449482504, 'mean_word_length': 3.4713656387665197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '243543', 'n_tokens_mistral': 677, 'n_tokens_neox': 634, 'n_words': 194}