<commit_before>package database

import "github.com/mebiusashan/beaker/common"

type TweetModelDB struct {
	common.TweetModel
}

func (TweetModelDB) TableName() string {
	return "tweets"
}

func (d *Dao) TweetFindByNum(page uint, num uint) ([]TweetModelDB, error) {
	var tw []TweetModelDB
	err := d.mysql.Order("id desc").Offset((page - 1) * num).Limit(num).Find(&tw).Error
	return tw, err
}

func (d *Dao) TweetCount() uint {
	var count uint = 0
	d.mysql.Table("tweets").Count(&count)
	return count
}

func (d *Dao) TweetAdd(content string) error {<commit_msg>if  tweet num is 0, return array length with zero<commit_after>package database

import "github.com/mebiusashan/beaker/common"

type TweetModelDB struct {
	common.TweetModel
}

func (TweetModelDB) TableName() string {
	return "tweets"
}

func (d *Dao) TweetFindByNum(page uint, num uint) ([]TweetModelDB, error) {
	var tw []TweetModelDB
	count := 0
	d.mysql.Model(&TweetModelDB{}).Count(&count)
	if count == 0 {
		return tw, nil
	}
	err := d.mysql.Order("id desc").Offset((page - 1) * num).Limit(num).Find(&tw).Error
	return tw, err
}

func (d *Dao) TweetCount() uint {
	var count uint = 0
	d.mysql.Table("tweets").Count(&count)
	return count
}

func (d *Dao) TweetAdd(content string) error {
{'fraction_non_alphanumeric': 0.14764565043894654, 'fraction_numerical': 0.00558659217877095, 'mean_word_length': 4.726027397260274, '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': '3901107', 'n_tokens_mistral': 478, 'n_tokens_neox': 475, 'n_words': 122}