<commit_before>package models

import (
  "fmt"
  "github.com/spacedock-io/registry/db"
)

type Tag struct {
  Id         int64
  Tag        string `sql:"not null"`
  ImageId    int64
  Repo       string `sql:"not null"`
  Namespace  string `sql:"not null"`
}

func CreateTag(namespace string, repo string, tag string, uuid string) error {
  image := &Image{}
  q := db.DB.Where("uuid = ?", uuid).Find(image)

  fmt.Printf("CreateTag uuid: %+v\n", uuid)
  fmt.Printf("CreateTag q: %+v\n", q)

  if q.RecordNotFound() {
    t := Tag{
      Tag: tag,
      Repo: repo,
      Namespace: namespace,
    }
    image.Tags = append(image.Tags, t)
    return image.Save()
  } else if q.Error != nil {
    return q.Error
  }

  return TagCreateErr
}

func GetTags(namespace string, repo string) ([]Tag, error) {
  var t []Tag
  q := db.DB.Where("Namespace = ? and Repo = ?", namespace, repo).Find(&t)
  if q.Error != nil {
    return nil, q.Error
  }
  return t, nil
}

func GetTag(namespace string, repo string, tag string) (*Tag, error) {
  t := &Tag{}
  q := db.DB.Where("Namespace = ? and Repo = ?", namespace, repo).Find(t)
  if q.Error != nil {
    return nil, q.Error
  }
  return t, nil
}

func (tag *Tag) Save() error {
  q := db.DB.Save(tag)
  if q.Error != nil {
    return TagSaveErr
  }
  return nil
}

func (tag *Tag) Create() error {
  return tag.Save()
}
<commit_msg>Fix `CreateTags` return value<commit_after>package models

import (
  "fmt"
  "github.com/spacedock-io/registry/db"
)

type Tag struct {
  Id         int64
  Tag        string `sql:"not null"`
  ImageId    int64
  Repo       string `sql:"not null"`
  Namespace  string `sql:"not null"`
}

func CreateTag(namespace string, repo string, tag string, uuid string) error {
  image := &Image{}
  q := db.DB.Where("uuid = ?", uuid).Find(image)

  fmt.Printf("CreateTag uuid: %+v\n", uuid)
  fmt.Printf("CreateTag q: %+v\n", q)

  if q.RecordNotFound() {
    t := Tag{
      Tag: tag,
      Repo: repo,
      Namespace: namespace,
    }
    image.Tags = append(image.Tags, t)
    return image.Save()
  } else if q.Error != nil {
    return q.Error
  }

  return nil
}

func GetTags(namespace string, repo string) ([]Tag, error) {
  var t []Tag
  q := db.DB.Where("Namespace = ? and Repo = ?", namespace, repo).Find(&t)
  if q.Error != nil {
    return nil, q.Error
  }
  return t, nil
}

func GetTag(namespace string, repo string, tag string) (*Tag, error) {
  t := &Tag{}
  q := db.DB.Where("Namespace = ? and Repo = ?", namespace, repo).Find(t)
  if q.Error != nil {
    return nil, q.Error
  }
  return t, nil
}

func (tag *Tag) Save() error {
  q := db.DB.Save(tag)
  if q.Error != nil {
    return TagSaveErr
  }
  return nil
}

func (tag *Tag) Create() error {
  return tag.Save()
}

{'fraction_non_alphanumeric': 0.15535390199637023, 'fraction_numerical': 0.0029038112522686023, 'mean_word_length': 2.744565217391304, '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': '599545', 'n_tokens_mistral': 1009, 'n_tokens_neox': 1006, 'n_words': 287}