package api

import (
	"github.com/ez-api/ez-api/internal/model"
	"github.com/ez-api/ez-api/internal/service"
	"gorm.io/gorm"
)

func logBaseQuery(db *gorm.DB, partitioner *service.LogPartitioner) *gorm.DB {
	if db == nil {
		return db
	}
	if partitioner != nil && partitioner.Enabled() {
		return db.Table(partitioner.ViewName() + " as log_records")
	}
	return db.Model(&model.LogRecord{})
}
