Skip to content

Commit

Permalink
[bench] replace new_item to new_items
Browse files Browse the repository at this point in the history
  • Loading branch information
catatsuy committed Sep 8, 2019
1 parent c90c309 commit ffd9823
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
20 changes: 10 additions & 10 deletions bench/scenario/check.go
Expand Up @@ -305,7 +305,7 @@ func checkNewCategoryItemsAndItems(ctx context.Context, s *session.Session, cate
category, ok := asset.GetCategory(categoryID)
if !ok || category.ParentID != 0 {
// benchmarkerのバグになるかと
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json カテゴリIDが正しくありません", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json カテゴリIDが正しくありません", categoryID))
}
itemIDs := newIDsStore()
err := checkItemIDsFromCategory(ctx, s, itemIDs, categoryID, 0, 0, 0, maxPage)
Expand All @@ -316,7 +316,7 @@ func checkNewCategoryItemsAndItems(ctx context.Context, s *session.Session, cate
// 全件はカウントできない。countUserItemsを何回か動かして確認している
// ここでは商品数はperpage*maxpage
if maxPage > 0 && int64(c) != maxPage*asset.ItemsPerPage {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json の商品数が正しくありません", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json の商品数が正しくありません", categoryID))
}

chkItemIDs := itemIDs.RandomIDs(checkItem)
Expand All @@ -343,22 +343,22 @@ func checkItemIDsFromCategory(ctx context.Context, s *session.Session, itemIDs *
return err
}
if loop < 50 && asset.ItemsPerPage != len(items) { // MEMO 50件よりはみないだろう
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json の商品数が正しくありません", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json の商品数が正しくありません", categoryID))
}
for _, item := range items {
if nextCreatedAt > 0 && nextCreatedAt < item.CreatedAt {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonはcreated_at順である必要があります", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonはcreated_at順である必要があります", categoryID))
}

if item.Category == nil {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
}
if item.Category.ParentID != categoryID {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
}

if item.Status != asset.ItemStatusOnSale && item.Status != asset.ItemStatusSoldOut {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json の商品のステータスが正しくありません (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json の商品のステータスが正しくありません (item_id: %d)", categoryID, item.ID))
}

aItem, ok := asset.GetItem(item.SellerID, item.ID)
Expand All @@ -368,17 +368,17 @@ func checkItemIDsFromCategory(ctx context.Context, s *session.Session, itemIDs *
}

if !(item.Name == aItem.Name) {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonの商品の名前が間違えています (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonの商品の名前が間違えています (item_id: %d)", categoryID, item.ID))
}

err := checkItemSimpleCategory(item, aItem)
if err != nil {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonの%s", categoryID, err.Error()))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonの%s", categoryID, err.Error()))
}

err = itemIDs.Add(item.ID)
if err != nil {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonに同じ商品がありました (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonに同じ商品がありました (item_id: %d)", categoryID, item.ID))
}
nextItemID = item.ID
nextCreatedAt = item.CreatedAt
Expand Down
16 changes: 8 additions & 8 deletions bench/scenario/load.go
Expand Up @@ -514,7 +514,7 @@ func loadNewCategoryItemsAndItems(ctx context.Context, s *session.Session, categ
category, ok := asset.GetCategory(categoryID)
if !ok || category.ParentID != 0 {
// benchmarkerのバグになるかと
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json カテゴリIDが正しくありません", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json カテゴリIDが正しくありません", categoryID))
}
itemIDs := newIDsStore()
err := loadItemIDsFromCategory(ctx, s, itemIDs, categoryID, 0, 0, 0, maxPage)
Expand Down Expand Up @@ -542,7 +542,7 @@ func loadNewCategoryItemsAndItems(ctx context.Context, s *session.Session, categ
// 全件はカウントできない。countUserItemsを何回か動かして確認している
// ここでは商品数はperpage*maxpage
if maxPage > 0 && int64(c) != maxPage*asset.ItemsPerPage {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json の商品数が正しくありません", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json の商品数が正しくありません", categoryID))
}

chkItemIDs := itemIDs.RandomIDs(checkItem)
Expand All @@ -569,28 +569,28 @@ func loadItemIDsFromCategory(ctx context.Context, s *session.Session, itemIDs *I
return err
}
if loop < 50 && len(items) != asset.ItemsPerPage { // MEMO 50ページ以上チェックすることはない
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json の商品数が正しくありません", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json の商品数が正しくありません", categoryID))
}
for _, item := range items {
if nextCreatedAt > 0 && nextCreatedAt < item.CreatedAt {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonはcreated_at順である必要があります", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonはcreated_at順である必要があります", categoryID))
}

if item.Category == nil {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
}

if item.Category.ParentID != categoryID {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
}

if item.Status != asset.ItemStatusOnSale && item.Status != asset.ItemStatusSoldOut {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json の商品のステータスが正しくありません (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json の商品のステータスが正しくありません (item_id: %d)", categoryID, item.ID))
}

err = itemIDs.Add(item.ID)
if err != nil {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonに同じ商品がありました (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonに同じ商品がありました (item_id: %d)", categoryID, item.ID))
}
nextItemID = item.ID
nextCreatedAt = item.CreatedAt
Expand Down
6 changes: 3 additions & 3 deletions bench/scenario/normal.go
Expand Up @@ -152,14 +152,14 @@ func findItemFromNewCategoryAll(ctx context.Context, s *session.Session, categor
}
for _, item := range items {
if nextCreatedAt > 0 && nextCreatedAt < item.CreatedAt {
return session.ItemSimple{}, failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonはcreated_at順である必要があります", categoryID))
return session.ItemSimple{}, failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonはcreated_at順である必要があります", categoryID))
}
if item.Category == nil {
return session.ItemSimple{}, failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json のカテゴリが返っていません (item_id: %d)", categoryID, item.ID))
return session.ItemSimple{}, failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json のカテゴリが返っていません (item_id: %d)", categoryID, item.ID))
}

if item.Category.ParentID != categoryID {
return session.ItemSimple{}, failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
return session.ItemSimple{}, failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
}

if item.ID == targetItemID {
Expand Down
22 changes: 11 additions & 11 deletions bench/scenario/verify.go
Expand Up @@ -489,7 +489,7 @@ func verifyNewCategoryItemsAndItems(ctx context.Context, s *session.Session, cat
category, ok := asset.GetCategory(categoryID)
if !ok || category.ParentID != 0 {
// benchmarkerのバグになるかと
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json カテゴリIDが正しくありません", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json カテゴリIDが正しくありません", categoryID))
}
itemIDs := newIDsStore()
err := verifyItemIDsFromCategory(ctx, s, itemIDs, categoryID, 0, 0, 0, maxPage)
Expand All @@ -500,7 +500,7 @@ func verifyNewCategoryItemsAndItems(ctx context.Context, s *session.Session, cat
// 全件はカウントできない。countUserItemsを何回か動かして確認している
// ここでは商品数はperpage*maxpage
if maxPage > 0 && int64(c) != maxPage*asset.ItemsPerPage {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json の商品数が正しくありません", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json の商品数が正しくありません", categoryID))
}

chkItemIDs := itemIDs.RandomIDs(checkItem)
Expand All @@ -527,42 +527,42 @@ func verifyItemIDsFromCategory(ctx context.Context, s *session.Session, itemIDs
return err
}
if loop < 50 && asset.ItemsPerPage != len(items) { // MEMO 50件よりはみないだろう
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json の商品数が正しくありません", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json の商品数が正しくありません", categoryID))
}
for _, item := range items {
if nextCreatedAt > 0 && nextCreatedAt < item.CreatedAt {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonはcreated_at順である必要があります", categoryID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonはcreated_at順である必要があります", categoryID))
}

if item.Category == nil {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json のカテゴリが返っていません (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json のカテゴリが返っていません (item_id: %d)", categoryID, item.ID))
}

if item.Category.ParentID != categoryID {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json のカテゴリが異なります (item_id: %d)", categoryID, item.ID))
}

aItem, ok := asset.GetItem(item.SellerID, item.ID)
if !ok {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonに不明な商品があります (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonに不明な商品があります (item_id: %d)", categoryID, item.ID))
}

if !(item.Name == aItem.Name) {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonの商品の名前が間違えています (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonの商品の名前が間違えています (item_id: %d)", categoryID, item.ID))
}

if item.Status != asset.ItemStatusOnSale && item.Status != asset.ItemStatusSoldOut {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.json の商品のステータスが正しくありません (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.json の商品のステータスが正しくありません (item_id: %d)", categoryID, item.ID))
}

err := checkItemSimpleCategory(item, aItem)
if err != nil {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonの%s", categoryID, err.Error()))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonの%s", categoryID, err.Error()))
}

err = itemIDs.Add(item.ID)
if err != nil {
return failure.New(fails.ErrApplication, failure.Messagef("/new_item/%d.jsonに同じ商品がありました (item_id: %d)", categoryID, item.ID))
return failure.New(fails.ErrApplication, failure.Messagef("/new_items/%d.jsonに同じ商品がありました (item_id: %d)", categoryID, item.ID))
}
nextItemID = item.ID
nextCreatedAt = item.CreatedAt
Expand Down

0 comments on commit ffd9823

Please sign in to comment.