From 55487309411b666d31b97de7b39590d5b5f1da93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Baldeweg?= <56736413+abaldeweg@users.noreply.github.com> Date: Tue, 29 Oct 2024 08:58:51 +0000 Subject: [PATCH] limit results to 100 --- gateway/core/repository/author.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/core/repository/author.go b/gateway/core/repository/author.go index 822f0f4..32d9e36 100644 --- a/gateway/core/repository/author.go +++ b/gateway/core/repository/author.go @@ -12,6 +12,8 @@ type AuthorRepository struct { const tableName = "author" +const limit = 100 + // NewAuthorRepository creates a new author repository. func NewAuthorRepository(db *gorm.DB) *AuthorRepository { return &AuthorRepository{db: db} @@ -20,7 +22,7 @@ func NewAuthorRepository(db *gorm.DB) *AuthorRepository { // FindAllByTerm returns all authors by term. func (r *AuthorRepository) FindAllByTerm(term string) ([]models.Author, error) { var authors []models.Author - result := r.db.Table(tableName).Where("firstname LIKE ? OR surname LIKE ? OR CONCAT(firstname, ' ', surname) LIKE ? OR CONCAT(surname, ' ', firstname) LIKE ? OR CONCAT(firstname, ',', surname) LIKE ? OR CONCAT(firstname, ', ', surname) LIKE ?", "%"+term+"%", "%"+term+"%", "%"+term+"%", "%"+term+"%", "%"+term+"%", "%"+term+"%").Find(&authors) + result := r.db.Table(tableName).Where("firstname LIKE ? OR surname LIKE ? OR CONCAT(firstname, ' ', surname) LIKE ? OR CONCAT(surname, ' ', firstname) LIKE ? OR CONCAT(firstname, ',', surname) LIKE ? OR CONCAT(firstname, ', ', surname) LIKE ?", "%"+term+"%", "%"+term+"%", "%"+term+"%", "%"+term+"%", "%"+term+"%", "%"+term+"%").Limit(limit).Find(&authors) return authors, result.Error }