ã³ã¼ããå®å ¨ã«ãã®ä¸ããæ¹æ¶ãã¦ãã
TL;DR
- ã¡ã³ãã楽ã«ããã«ã¯ã¡ã³ãããªãã®ãè¯ãã
- å¤ãã³ã¼ãã¯ç©æ¥µçã«æ¶ãã¦ããã¨ã¡ã³ãããªãã¦è¯ãã
- è¿éã«æ¶ãã¨ãã°ãããæ éã«ã
- ã¢ã¯ã»ã¹ãã°ã使ãã¨æ¶ããããªã®ãæ¢ããããã
- ã¨ã©ã¼æ¤ç¥ãã¼ã«ã§ä½¿ã£ã¦ãªãããã§ãã¯ããã¨å®å ¨ã ã
- å°ãã¥ã¤ã§ãé å¼µããããªãã
ã¯ããã«
é·ã使ããã¦ãããªãã¸ããªã§ã¯ãå¿ ç¶çã«ã¡ã³ãããã¹ãã³ã¼ãéãå¢ãã¦ããã¾ãããã®ãããå¤æ´ã«å¯¾ããå½±é¿ç¯å²ã®å¢å¤§ããã¹ãã»ãã«ãæéã®å¢å ãèµ·ããéçºé度ãä¸ãã£ã¦ããã¾ãã
ã³ã¼ãã®ã¡ã³ããæã楽ã«ããæ¹æ³ã®ä¸ã¤ã¯ãæ¶ãã¦ã¡ã³ãããªããã¨ãªã®ã§ãå¤ãã³ã¼ãã¯é©åã«ãªãã¡ã¯ã¿ãªã³ã°ãããã使ããã¦ããªãã³ã¼ãã¯åé¤ãããªã©ãå¢å ããã³ã¼ãã«å¯¾æãã¦ããå¿ è¦ãããã¾ãã
ç¹ã«APIãµã¼ãã®å ´åãäºææ§ãå´©ããå¤æ´ãªã®ã§/v1/meã®å¤ãã¨ã³ããã¤ã³ãã¯ãã®ã¾ã¾ã«ããæ°ãããã¼ã¸ã§ã³ããã¯/v2/meã®æ°ããã¨ã³ããã¤ã³ãã使ãâ¦ã¨ããç¨ã«ã移è¡ã®ããã«å¤ãã³ã¼ããæ®ããããã§ãã
ãã®ãããªå ´åã移è¡ãã¦ãã使ãããªããªã£ã/v1/meãã¡ã³ããç¶ããã®ã¯ã³ã¹ããããããããä¸å®ã®ã¿ã¤ãã³ã°ã§æ¶ãã¦ãã¾ãããã§ãã
å®éã«ã³ã¼ããã©ãæ¶ãã¦ããã
使ããã¦ããªããããªã³ã¼ããæ¶ãããã³ã¼ãããã£ãå ´åã«ããã®ã³ã¼ãã®ç¶æ³ã«ãã£ã¦ã©ãããæé ãåãã¹ããã¯å¤ãã£ã¦ãã¾ãã
ä»åã¯å®éã«æ¶ããå ´åã®æé ãã¾ã¨ãã¦ç´¹ä»ãã¾ããRailsã¢ããªã±ã¼ã·ã§ã³ãæ³å®ãã¦ãã¾ãããRailsç¹æã®é¨åã¯ããã¾ããã
æ¶ããããªã³ã¼ããè¦ä»ãã
ä½ã¯ã¨ãããæ¶ããããªã³ã¼ããè¦ä»ããã¨ããããã§ããæ¢ãæ¹æ³ã¯ããã¤ããããAPIã§ããã°ãã¼ã¸ã§ã³ã®ä½ãã¨ã³ããã¤ã³ãããé ã«è¦ã¦ãã£ãããã¢ã¯ã»ã¹ãã°ã¨rake routesã®çµæããã¢ã¯ã»ã¹ãã°ã«ãªãroutesãåºããå¶ç¶è¦ä»ããçæ¹æ³ã¯æ§ã ã§ãã
ä»åã®å ´åã¯å¤ãAPIãè¦ã¦ããéã«ãéå»ã«åé¤ããæ©è½ã«é¢ããã¡ã½ãããè¦ä»ã (Task#my_tasks ã¡ã½ããã¨ãã¾ã)ã対å¿ããã³ã¼ããæ¶ããªããã¨èã調æ»ãå§ããã¨ãããå¼ã³åºãå ã®ã¨ã³ããã¤ã³ã(/v1/tasksã¨ãã¾ã)ã使ããã¦ããªããããªã®ãçºè¦ãã¾ãããã¾ããrake rouetsçã§ã¨ã³ããã¤ã³ãä¸è¦§ãåºããå¾è¿°ã®ã¢ã¯ã»ã¹ãã°ã調ã¹ãæ¹æ³ã§ã¢ã¯ã»ã¹ãç¡ããã®ãæ´ãåºãã¦ããã®ãæå¹ã§ãã
# /v1/tasks
def index
@tasks = Task.my_tasks(user)
end
ã¢ã¯ã»ã¹ãã°ã調ã¹ã
å¼ç¤¾ã§ã¯ãã¨ãã¨ãã¼ã¿åæç¨ã«ã¢ã¯ã»ã¹ãã°ãAmazon Redshiftã«ä¿åããRedashä¸ã§æ±ããç°å¢ãæ´ãã¦ãããSQLãæ¸ãã ãã§ç°¡åã«ã¨ã³ããã¤ã³ãã¸ã®ã¢ã¯ã»ã¹ãã°ãéè¨ã§ãã¾ãã
ä»åæ¶ããã/v1/tasksã®éå»ã®ã¢ã¯ã»ã¹ãã°ã調ã¹ãã¨ã使ããªããªã£ããã¼ã¸ã§ã³ããªãªã¼ã¹ãã¦ããã»ã¼ã¢ã¯ã»ã¹ãç¡ããªããããæ°ã¶æã§ã¯ä¸åº¦ãã¢ã¯ã»ã¹ãç¡ãã¨ããäºããããã¾ããããã®ãããããããã¦è¯ãã¨ã¿ãªããã¨ã³ããã¤ã³ããåé¤ãããã¨ã«ãã¾ããã
ã¨ã©ã¼éç¥ãµã¼ãã¹ãå©ç¨ãã¦ä½¿ã£ã¦ãããã調ã¹ã
/v1/tasks/ã®ã¨ã³ããã¤ã³ãæ¶ãã ããªãã°ãcontrollerããæ¶ãã¦çµããã¾ãããã¨ã³ããã¤ã³ããæ¶ãããã¨ã«ããããã®ä¸ã§å¼ã³åºãã¦ããTask#my_tasksãæ¶ããå¯è½æ§ãããã¾ãã
å¤ãã®å ´åãã¡ã½ããã®å¼ã³åºãç¶æ³ã調ã¹ãã°æ¶ãããå¤æåºæ¥ã¾ãããã³ã¼ããè¤éã«çµ¡ã¿åã£ã¦ããå ´åãä¸è¦ä½¿ã£ã¦ããªãããã«è¦ãã¦ãå®ã¯ä½¿ã£ã¦ããã®ã§ã¯ãªããâ¦ã¨ãã£ãä¸å®ãææã§ãã¾ããã
ãã®ãããªå ´åãã¨ã©ã¼éç¥ãå©ç¨ãããã¨ã§å®å ¨ã«ä½¿ã£ã¦ããªããã調ã¹ããã¨ãã§ãã¾ãã
以ä¸ã®ããã«å°ç¨ã®ã¨ã©ã¼ãéç¥ãããã®å¾å ã®å¦çããããããªã³ã¼ãã«å¤æ´ãã¦æ¬çªã§ãã°ããæ§åãã¿ã¾ããæã«åãã¦ä½¿ããã¦ããã°ã¨ã©ã¼ãé£ã¶ã®ã§æ°ãã¤ãã¾ãããã¦ã¼ã¶ããè¦ãã¨ãã®æåã¯å¤ãããªããããå®å ¨ã«ä½¿ç¨ç¶æ³ã調ã¹ããã¾ãããã®æã大éã«ã¨ã©ã¼ãã°ãåºãã¨ä»ã®ã¨ã©ã¼ãåãããããéç¥å¦çã«ããããã«ããã¯ãèµ·ããã®ã§ãããã£ã¦ããç®æã«é¢ãã¦ã¯å ã«æ¶ãã¦ããã®ããå§ããã¾ãã
å¼ç¤¾ã§ã¯Sentryãå©ç¨ãã¦ãããRavenã使ã£ã¦ã¨ã©ã¼éç¥ã管çãã¦ãããããRaven.notifyã¡ã½ããã«å°ç¨ã®ã¨ã©ã¼ã渡ãã¦ãã¾ããå¼ç¤¾ã§ã¯Sentryã¸ã¯fluentdãçµç±ãã¦éã£ã¦ããã®ã§ãä¸ãä¸å¤§éã«å¼ã°ããæã«ãã°ãä»æãã¦ãã¾ã£ã¦ããç´æ¥ãã°éç¥ãµã¼ãã¹ã«éãã®ã«æ¯ã¹ã¦ãããç¨åº¦ã¯èããããã¨ããå©ç¹ãããã¾ãã(ãã°ãã¡ã¤ã«ãçµç±ãã¦éãã®ã«æ¯ã¹ãã¨ã¾ã ä¸å®ã¯æ®ãã¾ãã)
def my_tasks(me)
Raven.notify(Task::MyTasksCalled.new) all_tasks = Task.where(user: me) # æ¢åã³ã¼ã
all_tasks.eachâ¦â¦..
end
ã³ã¼ããæ¶ã
ã³ã¼ãä¸ã«ãå¼ãã§ããã¨ãããç¡ããæ¬çªç°å¢ã§ãå ¨ãã¨ã©ã¼ãé£ãã§ããªãããã§ããã°ãã»ã¼å®å¿ãã¦ã³ã¼ããåé¤ãããã¨ãã§ãã¾ãã
ãã®ä»
æ¶ãããã³ã¼ãã使ããã¦ããå ´å
ãããåã§ããæ¶ãã¾ããã
â¦ã¨ã¯ãããå®è£ ãããã©ã¼ãã³ã¹ãè¨è¨é¢ã®å¤±æãªã©ã§ä½¿ã£ã¦ããã³ã¼ããæ¶ãããã¨ããå ´åãããã¾ãããã®ãããªå ´åã¯ãæéã¯ãããã¾ãã使ã£ã¦ããå 容ã調ã¹ããªãã¡ã¯ã¿ãªã³ã°ããããå¥ã®ã¨ã³ããã¤ã³ãã«ç§»è¡ãã¦ããããªã©ãããæ¶ããç¶æ ã«æã£ã¦ããã¾ãããã
ã¢ã¯ã»ã¹æ¹æ³ãå¶å¾¡ãã
iOSãAndroidã¢ããªã®å ´åã¯ããã¼ã¸ã§ã³ã¢ãããã¦ã¼ã¶ã«å§ããããããã³ã³ããã¼ã«ãã«ããã§ãããå é¨ã®å¥ãµã¼ããªã©internalãªéä¿¡ã§ããã°ã³ã³ããã¼ã«å¯è½ã§ããFiNCã§ã¯ã»ã¼å ¨ã¦ã®ãµã¼ããRubyã使ã£ã¦ãããããã¯ã©ã¤ã¢ã³ãã©ã¤ãã©ãªç¨ã®gemãæä¾ããå¥ã®ã¨ã³ããã¤ã³ãã¸ã®ç§»è¡ãç°¡åã«ãããã¨ãããªã¯ã¨ã¹ãæã«ãã©ãããã®ã©ã®ãã¼ã¸ã§ã³ã®gemã§ã¢ã¯ã»ã¹ãããã¨ãã£ãæ å ±ãåéããã¨ããææ³ãä¸é¨ã§è©¦ãã¦ãã¾ãããã ããã¾ã å°å ¥ããã°ããã§ç¾æç¹ã§ã¯ç§»è¡ãå¿ è¦ãªç¶æ³ãèµ·ãã¦ããªãã®ã§ãç¶å ±ã«ãæå¾ ãã ããã
æå¾ã«
ã¡ã³ãã³ã¹ããä¸ããããã«ã¯ãæ¶ããã³ã¼ãã¯å¯è½ãªéãæ¶ãã¦ãããã³ã¼ããµã¤ãºãå°ããä¿ã£ã¦ããã®ãå¹æçã§ãããã ããè¿éã«ã³ã¼ããæ¶ãã¨ãã°ã®åå ã«ãªã£ã¦ãã¾ãã¾ãããã®ãããæ§ã ãªæ å ±ãé§ä½¿ããå½±é¿ç¯å²ã®å°ãããã®ãå®å ¨ãªã³ã¼ãããæ¶ãã¦ãããã¨ã§ãå®å¿ãã¤å®å ¨ã«ã³ã¼ããµã¤ãºãå°ãããã¦ãããã¨ãã§ãã¾ãã
ãã¾ã
ãã®è¨äºã¯åã«æ¸ããRuboCopãç¡çãªãæ¢åããã¸ã§ã¯ãã«å°å ¥ããã¨ããè¨äºã§æ¸ããRuboCopã®åãçµã¿ããçã¾ãã¾ãããRuboCopå°å ¥æã«å¤ãã³ã¼ããã大éã®éåãæ¤åºããããã¹ãããªããä¿®æ£ããã³ã¹ããé«ãããã¤ä¸è¦ä½¿ã£ã¦ããªãããã«è¦ããã®ã§ãä¿®æ£ãã¦ã¡ã³ããç¶ããããæ¶ãã¦ãã¾ã£ãæ¹ãä»å¾ã®ã¡ã³ãã³ã¹ããæµ®ããè¯ãã®ã§ã¯ï¼ã¨ããèæ¯ãããã¾ãã¾ãããä¸è¦ãªã³ã¼ããæ¶ãã¦ãããã¨ã§ãä¸è¨ã®ãããªLinterã®å°å ¥ãã¨ã¦ã楽ã«ãªãã®ã§ãç©æ¥µçã«æ¹æ¶ãã¦ãããã¨ããå§ããã¾ãã