<commit_before>package service

import (
	"github.com/mageddo/go-logging"
	"bk-api/dao"
	"context"
	"bk-api/entity"
	"strings"
	"fmt"
	"bk-api/errors"
	"database/sql"
	"bk-api/db"
)

const (
	SEARCH_MIN_SIZE = 4
)

type BookmarkService struct {
	ctx context.Context
	logger logging.Log
	bookmarkDAO dao.BookmarkDAO
}

func (s *BookmarkService) GetBookmarks(offset, quantity int, tag, query string) ([]entity.BookmarkEntity, int, error){

	// clearing the data
	tag = strings.TrimSpace(tag)
	query = strings.TrimSpace(query)

	if tag != "" {
		return s.bookmarkDAO.GetBookmarksByTagSlug(tag, offset, quantity)
	} else if query != "" {
		if len(query) < SEARCH_MIN_SIZE {
			return nil, -1, errors.NewServiceError(fmt.Sprintf("Search text must have %d characters at least", SEARCH_MIN_SIZE))
		}
		return s.bookmarkDAO.GetBookmarksByNameOrHTML(query, offset, quantity);<commit_msg>MG-402 reducing min charactes to 3<commit_after>package service

import (
	"github.com/mageddo/go-logging"
	"bk-api/dao"
	"context"
	"bk-api/entity"
	"strings"
	"fmt"
	"bk-api/errors"
	"database/sql"
	"bk-api/db"
)

const (
	SEARCH_MIN_SIZE = 3
)

type BookmarkService struct {
	ctx context.Context
	logger logging.Log
	bookmarkDAO dao.BookmarkDAO
}

func (s *BookmarkService) GetBookmarks(offset, quantity int, tag, query string) ([]entity.BookmarkEntity, int, error){

	// clearing the data
	tag = strings.TrimSpace(tag)
	query = strings.TrimSpace(query)

	if tag != "" {
		return s.bookmarkDAO.GetBookmarksByTagSlug(tag, offset, quantity)
	} else if query != "" {
		if len(query) < SEARCH_MIN_SIZE {
			return nil, -1, errors.NewServiceError(fmt.Sprintf("Search text must have %d characters at least", SEARCH_MIN_SIZE))
		}
		return s.bookmarkDAO.GetBookmarksByNameOrHTML(query, offset, quantity);
{'fraction_non_alphanumeric': 0.12647554806070826, 'fraction_numerical': 0.004496908375491849, 'mean_word_length': 4.686900958466453, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6581557', 'n_tokens_mistral': 683, 'n_tokens_neox': 653, 'n_words': 146}