Slide 1

Slide 1 text

© 2022 Cookpad Inc. ৿ཏສ৅ʹʮ͍͍Ͷʯ͢ΔͨΊͷ
 σʔλߏ଄ ΫοΫύουגࣜձࣾ ͳͲ΍· ͳͭ͜ / @pndcat

Slide 2

Slide 2 text

● ͳͲ΍· ͳͭ͜ / @pndcat ● ΫοΫύουגࣜձࣾ 2017೥ʙ ● 2ຊ໨ͷτʔΫͷ @osyoyu ͱҰॹʹಇ͍͍ͯ·͢ ● ࡢ೥ @asonas ͕ൃද͍ͯͨ͠αʔϏεͷ։ൃͷ࿩ ● ήʔϜΛͨ͠Γɺਪ͠׆ಈΛ͍ͯ͠·͢ 2 ࣗݾ঺հ

Slide 3

Slide 3 text

● ର৅ऀ ○ ৽نαʔϏεΛϦϦʔεͯ͠গ͠ܦͪɺϦϑΝΫλϦϯάΛ ߟ͍͑ͯΔਓ ○ ϙϦϞʔϑΟοΫؔ࿈Λͬ͘͟Γ஌͍ͬͯΔਓ ■ ࣌ؒͷ౎߹্ɺৄࡉʹ͍ͭͯ͸࿩͠·ͤΜ ○ kei-s ͞ΜͷൃදʢΞιγΤʔγϣϯͷϦϑΝΫλϦϯάʣ Λฉ͘ਓ 3 ͸͡Ίʹ

Slide 4

Slide 4 text

● ৽نαʔϏεʹ͓͚Δʮ͍͍Ͷʯͷཁ݅Λߟ͑Δ ● αʔϏε౰ॳʹઃܭͨ͠σʔλߏ଄ ● ࣦഊͨ͜͠ͱ ● ʮ͍͍Ͷʯͷσʔλߏ଄ͷ࠶ݕ౼ʙϦϑΝΫλϦϯά 4 ࿩͢͜ͱ

Slide 5

Slide 5 text

5 ● ৯඼ؔ࿈ͷاۀͱϢʔβʔΛͭͳ͙ίϛϡχέʔγϣ ϯϓϥοτϑΥʔϜ ϝʔΧʔζλ΢ϯͱ͸

Slide 6

Slide 6 text

6 ● اۀ͕ɺ঎඼Λ঺հͨ͠Γɺ঎඼ʹ߹͏Ϩγϐ΍೔ৗ ͷτϐοΫΛ౤ߘ͢Δ ϝʔΧʔζλ΢ϯͱ͸ τϐοΫ ঎඼ ※ػೳ໊͸τϐοΫε

Slide 7

Slide 7 text

7 ● Ϣʔβʔ͕ɺاۀͷൃ৴ʹ͍͍Ͷ΍ίϝϯτΛ͢Δ ϝʔΧʔζλ΢ϯͱ͸ ίϝϯτ ͍͍Ͷ

Slide 8

Slide 8 text

● ԿΛ͍͍Ͷ͢Δʁ → ʮ঎඼ʯɾʮτϐοΫʯ ● 1ͭͷϞϊʹରͯ͠Կճ͍͍ͶΛ͢Δʁ → 1ճ ● ͲΕ͘Β͍ͷظؒͰ࡞Δʁ → ૣ͘!!! 8 ʮ͍͍ͶʯػೳΛ࡞Δ ঎඼ τϐοΫ

Slide 9

Slide 9 text

● ʮ঎඼ʯͱʮτϐοΫʯʹɺ1ճʮ͍͍ͶʯΛ͢Δͷ ͸೉͘͠ͳͦ͞͏ 9 ʮ͍͍ͶʯΛ͢Δ͚ͩɾɾɾʁ

Slide 10

Slide 10 text

● ʮ঎඼ʯͱʮτϐοΫʯʹɺ1ճʮ͍͍ͶʯΛ͢Δͷ ͸೉͘͠ͳͦ͞͏ ● ͔͠͠ɺ ○ ʮ͍͍Ͷʯͷର৅͕ࠓޙ૿͑Δ͔΋͠Εͳ͍ 10 ʮ͍͍ͶʯΛ͢Δ͚ͩɾɾɾʁ

Slide 11

Slide 11 text

● ʮ঎඼ʯͱʮτϐοΫʯʹɺ1ճʮ͍͍ͶʯΛ͢Δͷ ͸೉͘͠ͳͦ͞͏ ● ͔͠͠ɺ ○ ʮ͍͍Ͷʯͷର৅͕ࠓޙ૿͑Δ͔΋͠Εͳ͍ ○ ϩάΠϯ͍ͯ͠ͳ͍Ϣʔβʔ΋ʮ͍͍ͶʯΛ͍ͨ͠ 11 ʮ͍͍ͶʯΛ͢Δ͚ͩɾɾɾʁ

Slide 12

Slide 12 text

● ͍͍Ͷͷର৅ ○ ঎඼ ○ τϐοΫ ● ͍͍ͶΛ͢Δଆ ○ ϩάΠϯϢʔβʔͷ͍͍Ͷ ○ ϩάΠϯ͍ͯ͠ͳ͍Ϣʔβʔͷ͍͍Ͷʢಗ໊͍͍Ͷʣ ● ʮ͍͍Ͷʯͷର৅͸ࠓޙ૿͑Δ͔΋͠Εͳ͍ 12 ٻΊΒΕ͍ͯΔʮ͍͍Ͷʯػೳ

Slide 13

Slide 13 text

● ର৅ผɺ͍͍Ͷɾಗ໊͍͍Ͷ͝ͱʹςʔϒϧΛ࡞Δ ○ product_likes ○ product_anonymous_likes ○ topic_likes ○ topic_anonymous_likes ● ϙϦϞʔϑΟοΫؔ࿈ ● STI 13 ʮ͍͍Ͷʯͷσʔλߏ଄

Slide 14

Slide 14 text

● ର৅ผɺ͍͍Ͷɾಗ໊͍͍Ͷ͝ͱʹςʔϒϧΛ࡞Δ ○ product_likes ○ product_anonymous_likes ○ topic_likes ○ topic_anonymous_likes ● ϙϦϞʔϑΟοΫؔ࿈ ● STI 14 ʮ͍͍Ͷʯͷσʔλߏ଄ ։ൃ͕ਐΉͱ࢓༷ɾৼΔ෣͍ɾڍಈ͕มߋ͞Ε͏Δ มߋʹ଱͑ΒΕΔΑ͏ʹγϯϓϧͳσʔλߏ଄ʹ͢Δ → ର৅ผɺ͍͍Ͷɾಗ໊͍͍Ͷ͝ͱʹςʔϒϧΛ࡞Δ

Slide 15

Slide 15 text

15 ॳظͷςʔϒϧߏ଄ product_likes product_id user_id product_anonymous_likes product_id like_identifier products id name ộ User ID (number) User ID ͕ͳ͍ͷͰϥϯμϜͳจࣈྻΛੜ੒ (string)

Slide 16

Slide 16 text

16 ॳظͷςʔϒϧߏ଄ product_likes product_id user_id product_anonymous_likes product_id like_identifier products id name ộ User ID (number) User ID ͕ͳ͍ͷͰϥϯμϜͳจࣈྻΛੜ੒ (string) ҟͳΔσʔλΛಉ͡ΧϥϜʹೖΕΔͷ͸ෳࡶ ͍͍Ͷͱɺಗ໊͍͍Ͷ͸ผͷςʔϒϧͰఆٛ

Slide 17

Slide 17 text

● ʮ͍͍Ͷʯͷର৅͕૿͑ΔͨͼʹɺςʔϒϧɾϞσϧɾ ίϯτϩʔϥʔΛຖճ௥Ճ͢ΔͷͰͭΒ͍ ○ ঎඼ɺτϐοΫɺΫνίϛɺίϝϯτ (8ςʔϒϧ) 17 ࣦഊͨ͠ͱ͜Ζ product_likes product_id user_id product_anonymous_likes product_id like_identifier topic_likes topic_id user_id kuchikomi_likes kuchikomi_id user_id comment_likes comment_id user_id topic_anonymous_likes topic_id like_identifier comment_anonymous_likes comment_id like_identifier kuchikomi_anonymous_likes kuchikomi_id like_identifier

Slide 18

Slide 18 text

● ʮ͍͍Ͷʯͷର৅͕૿͑ΔͨͼʹɺςʔϒϧɾϞσϧɾ ίϯτϩʔϥʔΛຖճ௥Ճ͢ΔͷͰͭΒ͍ ○ ঎඼ɺτϐοΫɺΫνίϛɺίϝϯτ (8ςʔϒϧ) ● ͍͍Ͷ਺ͷूܭόονͰɺ৽͍͠ର৅ͷूܭΛ๨Εͨ 18 ࣦഊͨ͠ͱ͜Ζ ͋Δ࣌ؒ (time) Ҏ߱ʹ࡞੒͞Εͨʮ͍͍Ͷ਺ʯΛूܭ͢Δ

Slide 19

Slide 19 text

● ঎඼ɺτϐοΫɺίϝϯτɺΫνίϛͷʮ͍͍Ͷʯͷ ৼΔ෣͍͸શ෦ಉͩͬͨ͜͡ͱ͕Θ͔ͬͨ ○ Ϣʔβʔ͕ʮ͍͍ͶʯΛ͢Δ ○ ʮ͍͍Ͷʯ਺Λදࣔ͢Δ ○ ʮ͍͍Ͷʯ਺ͷूܭΛ͢Δ 19 ਅʹʮ͍͍ͶʯʹٻΊΒΕ͍ͯΔػೳͱ͸ʁ

Slide 20

Slide 20 text

● ঎඼ɺτϐοΫɺίϝϯτɺΫνίϛͷʮ͍͍Ͷʯͷ ৼΔ෣͍͸શ෦ಉͩͬͨ͜͡ͱ͕Θ͔ͬͨ ○ Ϣʔβʔ͕ʮ͍͍ͶʯΛ͢Δ ○ ʮ͍͍Ͷʯ਺Λදࣔ͢Δ ○ ʮ͍͍Ͷʯ਺ͷूܭΛ͢Δ ● ࠓޙ΋ʮ͍͍ͶʯผͷৼΔ෣͍͸ͳͦ͞͏ 20 ਅʹʮ͍͍ͶʯʹٻΊΒΕ͍ͯΔػೳͱ͸ʁ

Slide 21

Slide 21 text

● ϙϦϞʔϑΟοΫؔ࿈: 1ͭͷϞσϧΛෳ਺ͷϞσϧʹؔ࿈͚ͮΔ ○ Like ϞσϧΛ࡞Δ ○ ڞ௨ͷৼΔ෣͍Λ͢Δ৔߹͸ڧྗͳσʔλߏ଄ ■ if จΛॻ͘ͱഁ୼͢Δ ● STI: ܧঝΛ࢖ͬͯςʔϒϧΛ1ͭʹ͢Δ ○ ProductLike ͸ Like Λܧঝ͢Δ ○ ֤ʮ͍͍ͶʯΫϥεͰৼΔ෣͍Λগ͠ม͑Δ͜ͱ͕Ͱ͖Δ ■ ࣗ༝౓্͕͕ΔͷͰෛ࠴͕ੜ·ΕΔՄೳੑ͕ߴ͍ 21 ৽͍͠ʮ͍͍Ͷʯͷσʔλߏ଄ͷީิ

Slide 22

Slide 22 text

● ϙϦϞʔϑΟοΫؔ࿈: 1ͭͷϞσϧΛෳ਺ͷϞσϧʹؔ࿈͚ͮΔ ○ Like ϞσϧΛ࡞Δ ○ ڞ௨ͷৼΔ෣͍Λ͢Δ৔߹͸ڧྗͳσʔλߏ଄ ■ if จΛॻ͘ͱഁ୼͢Δ ● STI: ܧঝΛ࢖ͬͯςʔϒϧΛ1ͭʹ͢Δ ○ ProductLike ͸ Like Λܧঝ͢Δ ○ ֤ʮ͍͍ͶʯΫϥεͰৼΔ෣͍Λগ͠ม͑Δ͜ͱ͕Ͱ͖Δ ■ ࣗ༝౓্͕͕ΔͷͰෛ࠴͕ੜ·ΕΔՄೳੑ͕ߴ͍ 22 ৽͍͠ʮ͍͍Ͷʯͷσʔλߏ଄ͷީิ ● ʮ͍͍Ͷʯ͸ɺڞ௨ͷৼΔ෣͍ͰදݱͰ͖Δ ● if จΛઈରʹॻ͔ͳ͍ͱ͍͏ڧ͍ҙࢤͰϙϦ ϞʔϑΟοΫؔ࿈ʹ͢Δ

Slide 23

Slide 23 text

● ݁ہʮ͍͍Ͷʯ͸ɺ୯७ͳ࢓༷ͩͬͨ ○ ͔͠͠ɺαʔϏε։ൃΛਐΊͳ͍ͱΘ͔Βͳ͍ ● ࠷ॳ͸มߋʹ଱͑ΒΕΔΑ͏ͳσʔλߏ଄ʹ͢Δ ● ࣮૷͕ෳࡶʹͳͬͨΒσʔλߏ଄Λݟ௚͢
 ● ϙϦϞʔϑΟοΫؔ࿈ͷσʔλߏ଄ͷ࿩ͱɺϦϑΝΫ λϦϯάͷ࿩Λ͠·͢ 23 ඞཁͳλΠϛϯάͰσʔλߏ଄Λݟ௚͢

Slide 24

Slide 24 text

24 ৽͍͠σʔλߏ଄: likes (Like) product_likes product_id user_id product_anonymous_likes product_id like_identifier topic_likes topic_id user_id topic_anonymous_likes topic_id like_identifier likes likable_id likable_type user_id anonymous_likes likable_id likable_type like_identifier ● likes ͱ anonymous_likes ͷ2छྨʹ·ͱΊΔ ○ user_id ͱ like_identifier ͸ҟͳΔσʔλͷͨΊɺಉ͡ςʔϒϧʹ͸͠ ͳ͍

Slide 25

Slide 25 text

25 4ͭͷϞσϧ͕1ͭͷ Like ϞσϧͰදݱ before after ʮ͍͍Ͷʯͷର৅͕૿΍ͤΔʂ ৿ཏສ৅ͷ Like Ϟσϧ 🌲

Slide 26

Slide 26 text

1. ৽چͷʮ͍͍Ͷʯςʔϒϧʹॻ͖ࠐΉ (Write) 2. چ͍͍ͶΛ৽͍͍ͶʹϚΠάϨʔγϣϯ (όον) 3. ৽͍͠ʮ͍͍ͶʯΛ࢖͏ (Read) 4. چ͍͍ͶͷϞσϧͱςʔϒϧΛ࡟আ 26 ϦϑΝΫλϦϯά (Ҡߦͷઓུ)

Slide 27

Slide 27 text

27 1. ৽چͷʮ͍͍Ͷʯςʔϒϧʹॻ͖ࠐΉ (Write)

Slide 28

Slide 28 text

28 1. ৽چͷʮ͍͍Ͷʯςʔϒϧʹॻ͖ࠐΉ (Write)

Slide 29

Slide 29 text

29 2. چ͍͍ͶΛ৽͍͍ͶʹϚΠάϨʔγϣϯ (όον) product_likes product_id user_id likes likable_id 
 likable_type user_id VQTFSU@BMM͸ϚΠάϨʔγϣϯʹศརʂ

Slide 30

Slide 30 text

30 3. ৽͍͠ʮ͍͍ͶʯΛ࢖͏ (Read) ● ྫ: ঎඼ͷ͍͍Ͷ

Slide 31

Slide 31 text

31 3. ৽͍͠ʮ͍͍ͶʯΛ࢖͏ (Read) ● ͢΂ͯͷ͍͍Ͷͷ߹ࢉ (঎඼ɺτϐοΫ etc...)

Slide 32

Slide 32 text

32 3. ৽͍͠ʮ͍͍ͶʯΛ࢖͏ (Read) ● ͢΂ͯͷ͍͍Ͷͷ߹ࢉ (঎඼ɺτϐοΫ etc...) શ͍͍Ͷʹڞ௨ͷॲཧΛॻ͘ͱ͖͕ศར

Slide 33

Slide 33 text

33 4. چ͍͍ͶͷϞσϧͱςʔϒϧΛ࡟আ ● ৽͍͍ͶΛࢀরͨ͠Βɺچ͍͍Ͷͷॻ͖ࠐΈΛফ͢ ● چ͍͍ͶͷϞσϧɾςʔϒϧΛ࡟আ
 ● ϙϦϞʔϑΟοΫؔ࿈΁ͷҠߦ͕׬ྃ🎉

Slide 34

Slide 34 text

● ProductLikesController ͱ TopicLikesController͸ɺ΄ ΅ಉ͡ ○ ʮ͍͍Ͷʯͷॻ͖ࠐΈͱྫ֎ॲཧΛຖճॻ͘ͷ΋େม ○ ʮ͍͍Ͷʯͷॻ͖ࠐΈͱྫ֎ॲཧΛ Concern Ͱڞ௨Խ͢Δ ■ ஫ҙɿϨίʔυߋ৽͢Δʹؔ͢Δ΋ͷ͚ͩΛڞ௨Խ 34 ޻෉ͨ͠ͱ͜Ζ

Slide 35

Slide 35 text

35 Likable module -JLFΛ࡞੒ TFU@MJLBCMFΛ CFGPSF@BDUJPOͰݺͿ ྫ֎ॲཧ

Slide 36

Slide 36 text

● create ϝιουͷத਎͸ Likable module ʹ ● set_likable Ͱ likable Λࢦఆ͢Δ ○ likable =ʮ͍͍Ͷʯ͞ΕΔର৅ͷ͜ͱ (ྫ: product) 36 ֤ LikesController ͕؆ܿʹʂ Products::LikesController Topics::LikesController

Slide 37

Slide 37 text

● ࣅ͍ͯΔ͚Ͳͪΐͬͱҧ͏ʮ͍͍Ͷʯͷઃܭͷ঺հ ○ αʔϏεϦϦʔεޙʹϙϦϞʔϑΟοΫؔ࿈ʹมߋ ■ มߋ͕Ͱ͖ΔΑ͏ʹ࠷ॳ͸γϯϓϧͳσʔλߏ଄ʹ͢Δ ■ ʮ͍͍ͶʯͷৼΔ෣͍͕ಉ͔ͩ͡ΒҠߦͰ͖ͨ ● ϙϦϞʔϑΟοΫؔ࿈΁ͷϦϑΝΫλϦϯάͷ঺հ ○ Controller ͷ Concern ΋ಋೖ ● ৿ཏສ৅ʹʮ͍͍Ͷʯ͢ΔͨΊͷσʔλߏ଄͕׬੒👏 37 ·ͱΊ

Slide 38

Slide 38 text

38