<commit_before>package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {
	teamKey := "TODO"
	apiKey := "TODO"
	url := fmt.Sprintf("https://%s.backlog.jp/api/v2/notifications?apiKey=%s", teamKey, apiKey)
	r, _ := http.Get(url)
	defer r.Body.Close()
	bytes, _ := ioutil.ReadAll(r.Body)
	fmt.Println(string(bytes))
}

type NotificationResponse struct {
	AlreadyRead bool `json:"alreadyRead"`
	Comment     struct {
		ChangeLog []struct {
		AttachmentInfo   interface{} `json:"attachmentInfo"`<commit_msg>通知をunmarshalして一覧出力<commit_after>package main

import (
	"fmt"
	"net/http"
	"encoding/json"
	"io/ioutil"
	"log"
	"time"
)

func main() {
	teamKey := "TODO"
	apiKey := "TODO"
	notifications := getNotifications(teamKey, apiKey)
	notifications = collectUnreadNotifications(notifications)
	if len(notifications) == 0 {
		return
	}
	fmt.Printf("unread count: %d", len(notifications))
	for _, n := range notifications {
		fmt.Printf("comment: %s (%s)", n.Comment.Content, n.Created)
	}
}

func parseDateString(d string) time.Time {
	t, _ := time.Parse("2006-01-02T15:04:05Z", d)
	return t
}

func collectUnreadNotifications(notifications []NotificationResponse) []NotificationResponse {
	r := make([]NotificationResponse, 0)
	for _, n := range notifications {
		if !n.AlreadyRead {
			fmt.Println(n)
			r = append(r, n)
		}
	}
	return r
}

func getNotifications(teamKey string, apiKey string) []NotificationResponse {
	url := fmt.Sprintf("https://%s.backlog.jp/api/v2/notifications?apiKey=%s", teamKey, apiKey)
	r, _ := http.Get(url)
	defer r.Body.Close()
	var notifications []NotificationResponse
	bytes, _ := ioutil.ReadAll(r.Body)
	error := json.Unmarshal(bytes, &notifications)
	if error != nil {
		log.Fatalln(error)
	}
	return notifications
}

type NotificationResponse struct {
	AlreadyRead bool `json:"alreadyRead"`
	Comment     struct {
		ChangeLog []struct {
		AttachmentInfo   interface{} `json:"attachmentInfo"`
{'fraction_non_alphanumeric': 0.14922279792746113, 'fraction_numerical': 0.00932642487046632, 'mean_word_length': 4.816265060240964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6209597', 'n_tokens_mistral': 730, 'n_tokens_neox': 695, 'n_words': 141}