<commit_before>package db

import (
  "errors"
  "fmt"
  "strings"
)

func GetNotesList(username string) ([]string, error) {
  query := "SELECT note FROM notes WHERE username = ?"
  notesMap, err := GetQueryResultsMap(query, username)
  if err != nil {
    return []string{}, err
  }
}

func UpdateUserNotes(username string, notes []string) (error) {
  fmt.Println("call")
  if err := removeOldNotes(username, notes); err != nil {
    return err
  }
	return addNewNotes(username, notes)
}

func removeOldNotes(username string, notes []string) (error) {
  return PostDeleteQuery("DELETE FROM notes WHERE username = ?", username)
}

func addNewNotes(username string, notes []string) (error) {
  db := GetDatabaseInstance()
  if len(notes) == 0 { return errors.New("No Notes Found") }
  query := "INSERT INTO notes (username, note) VALUES "
  params := make([]interface{}, 0)

  for _, note := range notes {
    query += "(?, ?),"
    params = append(params, username, note)
  }
  query = strings.TrimSuffix(query, ",")

  _, err := db.Exec(query, params...)
  return err
}<commit_msg>added mapKeys()<commit_after>package db

import (
  "errors"
  "fmt"
  "strings"
)

func GetNotesList(username string) ([]string, error) {
  query := "SELECT note FROM notes WHERE username = ?"
  notesMap, err := GetQueryResultsMap(query, username)
  if err != nil {
    return []string{}, err
  }
  return mapKeys(notesMap), nil
}

func UpdateUserNotes(username string, notes []string) (error) {
  fmt.Println("call")
  if err := removeOldNotes(username, notes); err != nil {
    return err
  }
	return addNewNotes(username, notes)
}

func mapKeys(mapForKeys map[string]bool) ([]string) {
  keys := make([]string, 0, len(mapForKeys))
  for key := range mymap {
      keys = append(keys, key)
  }
  return keys
}

func removeOldNotes(username string, notes []string) (error) {
  return PostDeleteQuery("DELETE FROM notes WHERE username = ?", username)
}

func addNewNotes(username string, notes []string) (error) {
  db := GetDatabaseInstance()
  if len(notes) == 0 { return errors.New("No Notes Found") }
  query := "INSERT INTO notes (username, note) VALUES "
  params := make([]interface{}, 0)

  for _, note := range notes {
    query += "(?, ?),"
    params = append(params, username, note)
  }
  query = strings.TrimSuffix(query, ",")

  _, err := db.Exec(query, params...)
  return err
}
{'fraction_non_alphanumeric': 0.15025252525252525, 'fraction_numerical': 0.0021043771043771043, 'mean_word_length': 4.0574468085106385, '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': '703102', 'n_tokens_mistral': 775, 'n_tokens_neox': 744, 'n_words': 221}