BREAKING CHANGE: store repos under a subdir of the mapper id

This commit is contained in:
Michael Zhang 2020-10-12 09:35:51 -05:00
parent 6b60c43b00
commit eabf16899e
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
3 changed files with 5 additions and 5 deletions

View file

@ -100,7 +100,7 @@ func (bot *Bot) NotifyNewBeatmap(channels []string, newMaps []osuapi.Beatmapset)
// try to open a repo for this beatmap
var repo *git.Repository
repoDir := path.Join(bot.config.Repos, strconv.Itoa(beatmapSet.ID))
repoDir := path.Join(bot.config.Repos, strconv.Itoa(beatmapSet.UserID), strconv.Itoa(beatmapSet.ID))
if _, err := os.Stat(repoDir); os.IsNotExist(err) {
os.MkdirAll(repoDir, 0777)
}
@ -181,11 +181,11 @@ func (bot *Bot) NotifyNewBeatmap(channels []string, newMaps []osuapi.Beatmapset)
Title: fmt.Sprintf("Update: %s - %s", beatmapSet.Artist, beatmapSet.Title),
Timestamp: eventTime.Format(time.RFC3339),
Author: &discordgo.MessageEmbedAuthor{
URL: "https://osu.ppy.sh/u/" + strconv.Itoa(beatmapSet.UserId),
URL: "https://osu.ppy.sh/u/" + strconv.Itoa(beatmapSet.UserID),
Name: beatmapSet.Creator,
IconURL: fmt.Sprintf(
"https://a.ppy.sh/%d?%d.png",
beatmapSet.UserId,
beatmapSet.UserID,
time.Now().Unix(),
),
},

View file

@ -14,7 +14,7 @@ type Beatmapset struct {
Title string `json:"title"`
TitleUnicode string `json:"title_unicode"`
Creator string `json:"creator"`
UserId int `json:"user_id"`
UserID int `json:"user_id"`
Covers BeatmapCovers `json:"covers"`
Beatmaps []Beatmap `json:"beatmaps,omitempty"`

View file

@ -50,7 +50,7 @@ func RunScraper(config *config.Config, bot *discord.Bot, db *db.Db, api *osuapi.
break
}
mapperId := beatmapSet.UserId
mapperId := beatmapSet.UserID
if _, ok := trackedMappers[mapperId]; ok {
if _, ok2 := allNewMaps[mapperId]; !ok2 {
allNewMaps[mapperId] = make([]osuapi.Beatmapset, 0)