package seeds

import (
	"narasi-ahli-be/app/database/entity"

	"gorm.io/gorm"
)

type ActivityLogsSeeder struct{}

var activityLogTypes = []entity.ActivityLogTypes{
	{
		ID:       1,
		Name:     "Login",
		IsActive: true,
	},
	{
		ID:       2,
		Name:     "View",
		IsActive: true,
	},
	{
		ID:       3,
		Name:     "Share",
		IsActive: true,
	},
	{
		ID:       4,
		Name:     "Comment",
		IsActive: true,
	},
}

func (ActivityLogsSeeder) Seed(conn *gorm.DB) error {
	for _, row := range activityLogTypes {
		if err := conn.Create(&row).Error; err != nil {
			return err
		}
	}

	return nil
}

func (ActivityLogsSeeder) Count(conn *gorm.DB) (int, error) {
	var count int64
	if err := conn.Model(&entity.ActivityLogTypes{}).Count(&count).Error; err != nil {
		return 0, err
	}

	return int(count), nil
}
