<commit_before>CREATE FUNCTION fits.add_site(networkID_n TEXT, siteID_n TEXT, name_n TEXT, longitude_n NUMERIC, latitude_n NUMERIC, height_n NUMERIC, ground_relationship_n NUMERIC) RETURNS VOID AS
$$
DECLARE
tries INTEGER = 0;
BEGIN
LOOP
UPDATE fits.site 
SET height = height_n, ground_relationship = ground_relationship_n, location =  ST_GeogFromWKB(st_AsEWKB(st_setsrid(st_makepoint(longitude_n, latitude_n), 4326))) 
WHERE siteID = siteID_n 
AND networkpk = (select networkpk from fits.network where networkID = networkID_n);
IF found THEN
RETURN;
END IF;

BEGIN
INSERT INTO fits.site(siteID, name, networkpk, location, height, ground_relationship) 
SELECT siteID_n, name_n, networkpk, ST_GeogFromWKB(st_AsEWKB(st_setsrid(st_makepoint(longitude_n, latitude_n), 4326))), height_n, ground_relationship_n
from fits.network 
where networkID = networkID_n;
RETURN;
EXCEPTION WHEN unique_violation THEN
--  Loop once more to see if a different insert happened after the update but before our insert.
tries = tries + 1;
if tries > 1 THEN
RETURN;
END IF;
END;
END LOOP;
END;
$$<commit_msg>Update name for sites as well.<commit_after>CREATE FUNCTION fits.add_site(networkID_n TEXT, siteID_n TEXT, name_n TEXT, longitude_n NUMERIC, latitude_n NUMERIC, height_n NUMERIC, ground_relationship_n NUMERIC) RETURNS VOID AS
$$
DECLARE
tries INTEGER = 0;
BEGIN
LOOP
UPDATE fits.site 
SET height = height_n, ground_relationship = ground_relationship_n, name = name_n, location =  ST_GeogFromWKB(st_AsEWKB(st_setsrid(st_makepoint(longitude_n, latitude_n), 4326))) 
WHERE siteID = siteID_n 
AND networkpk = (select networkpk from fits.network where networkID = networkID_n);
IF found THEN
RETURN;
END IF;

BEGIN
INSERT INTO fits.site(siteID, name, networkpk, location, height, ground_relationship) 
SELECT siteID_n, name_n, networkpk, ST_GeogFromWKB(st_AsEWKB(st_setsrid(st_makepoint(longitude_n, latitude_n), 4326))), height_n, ground_relationship_n
from fits.network 
where networkID = networkID_n;
RETURN;
EXCEPTION WHEN unique_violation THEN
--  Loop once more to see if a different insert happened after the update but before our insert.
tries = tries + 1;
if tries > 1 THEN
RETURN;
END IF;
END;
END LOOP;
END;
$$
{'fraction_non_alphanumeric': 0.07590909090909091, 'fraction_numerical': 0.01, 'mean_word_length': 6.48639455782313, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3269376', 'n_tokens_mistral': 822, 'n_tokens_neox': 737, 'n_words': 233}