<commit_before>package repository

import (
	"github.com/lib/pq"
	"github.com/syou6162/go-active-learning/lib/model"
)

var hatenaBookmarkNotFoundError = model.NotFoundError("hatenaBookmark")

func (r *repository) UpdateHatenaBookmark(e *model.Example) error {
	if e.HatenaBookmark == nil || e.HatenaBookmark.Count == 0 {
		return nil
	}

	tmp, err := r.FindExampleByUlr(e.Url)
	if err != nil {
		return err
	}
	id := tmp.Id

	e.HatenaBookmark.ExampleId = id
	if _, err = r.db.NamedExec(`
INSERT INTO hatena_bookmark
( example_id,  title,  screenshot,  entry_url,  count,  url,  eid)
VALUES
(:example_id, :title, :screenshot, :entry_url, :count, :url, :eid)
ON CONFLICT (example_id)
DO UPDATE SET
title = :title, screenshot = :screenshot, entry_url = :entry_url, count = :count, url = :url, eid = :eid
;`, e.HatenaBookmark); err != nil {
		return err<commit_msg>変更がありうる要素に絞る<commit_after>package repository

import (
	"github.com/lib/pq"
	"github.com/syou6162/go-active-learning/lib/model"
)

var hatenaBookmarkNotFoundError = model.NotFoundError("hatenaBookmark")

func (r *repository) UpdateHatenaBookmark(e *model.Example) error {
	if e.HatenaBookmark == nil || e.HatenaBookmark.Count == 0 {
		return nil
	}

	tmp, err := r.FindExampleByUlr(e.Url)
	if err != nil {
		return err
	}
	id := tmp.Id

	e.HatenaBookmark.ExampleId = id
	if _, err = r.db.NamedExec(`
INSERT INTO hatena_bookmark
( example_id,  title,  screenshot,  entry_url,  count,  url,  eid)
VALUES
(:example_id, :title, :screenshot, :entry_url, :count, :url, :eid)
ON CONFLICT (example_id)
DO UPDATE SET
title = :title, count = :count
;`, e.HatenaBookmark); err != nil {
		return err
{'fraction_non_alphanumeric': 0.13583990297149787, 'fraction_numerical': 0.006064281382656155, 'mean_word_length': 4.593220338983051, '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': '908002', 'n_tokens_mistral': 669, 'n_tokens_neox': 643, 'n_words': 145}