いつ〇〇の記事を出すのがベストなのか？

## 競馬予測の記事を書きたいが、いつの時期に出すのがベストなのだろうか  
今年の4-9月に社内活動の一環で、初心者同士で競馬予測のモデルを作った。せっかくだからQiita記事にまとめたいが、競馬予測の記事はすでに数多く存在するため、良い感じの時期に記事を出したいと思い、QiitaAPIを使って調査した。  
（競馬予測というワードを〇〇に変更することで自分の出したい記事について調べることができます！）
　　
【良い感じの時期とは】  
"競馬予測"を含む記事の出現回数が少ない時期  
  
※検索回数は年間を通じて一定とする。  
(とすると出現回数が少ないほうが読者の目に止まりやすくなるはず)


## 環境設定  
・Node-RED (ver3.0.2)
・FlowForge
・[Qiita API]('https://qiita.com/api/v2/docs')


## 分析方法  
使用したフロー図とJSONは以下の通り。

![hw1_fig1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3565590/69a3248c-69be-965d-a67c-c7c7c8e794a8.png)

```  
[{"id":"c773b77127f04f37","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"2ad09c421d2bd55b","type":"inject","z":"c773b77127f04f37","name":"","props":[{"p":"payload"},{"p":"output","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":250,"y":280,"wires":[["4febbfe33b16288b","ad90bcaedee7d605","babc5c6bd0b709eb","9d5365d2d1081561","bd734f4a16865016","3defbdd2c59ec458","babb2f4f18273d62","702a55f34a1849ec","c7a380193343ae40","26b3b2f83c68eb4f","6bbb4183929684b6","33db1ef1080d6ed8"]]},{"id":"4febbfe33b16288b","type":"http request","z":"c773b77127f04f37","name":"2023/2Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2023-07-01+created:<2023-09-30","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":60,"wires":[["d44c9a5fe1b710bc"]]},{"id":"ad90bcaedee7d605","type":"http request","z":"c773b77127f04f37","name":"2023/1Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2023-04-01+created:<2023-07-31","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":100,"wires":[["f0713e0a6cea03cd"]]},{"id":"d44c9a5fe1b710bc","type":"debug","z":"c773b77127f04f37","name":"2023/2Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":".payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":60,"wires":[]},{"id":"babc5c6bd0b709eb","type":"http request","z":"c773b77127f04f37","name":"2022/4Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2023-01-01+created:<2023-03-30","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":140,"wires":[["bcb345b7ecf82749"]]},{"id":"9d5365d2d1081561","type":"http request","z":"c773b77127f04f37","name":"2022/3Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2022-10-01+created:<2022-12-31","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":180,"wires":[["85ddda06eae24fc7"]]},{"id":"bd734f4a16865016","type":"http request","z":"c773b77127f04f37","name":"2022/2Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2022-07-01+created:<2022-09-30","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":220,"wires":[["3d46b8e8fda4d0ad"]]},{"id":"3defbdd2c59ec458","type":"http request","z":"c773b77127f04f37","name":"2022/1Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2022-04-01+created:<2022-07-31","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":260,"wires":[["0c2866566388e57c"]]},{"id":"babb2f4f18273d62","type":"http request","z":"c773b77127f04f37","name":"2021/4Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2022-01-01+created:<2022-03-31","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":300,"wires":[["f9f8b3ae14d9be87"]]},{"id":"702a55f34a1849ec","type":"http request","z":"c773b77127f04f37","name":"2021/3Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2021-10-01+created:<2021-12-31","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":340,"wires":[["d4ea2d6b40fc064c"]]},{"id":"26b3b2f83c68eb4f","type":"http request","z":"c773b77127f04f37","name":"2021/1Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2021-04-01+created:<2023-06-30","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":420,"wires":[["0dbc8709701705ac"]]},{"id":"6bbb4183929684b6","type":"http request","z":"c773b77127f04f37","name":"2020/4Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2021-01-01+created:<2021-03-31","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":460,"wires":[["a290e8ae1506ac53"]]},{"id":"33db1ef1080d6ed8","type":"http request","z":"c773b77127f04f37","name":"2020/3Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2020-10-01+created:<2020-12-31","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":500,"wires":[["1067c0b3007db4d0"]]},{"id":"c7a380193343ae40","type":"http request","z":"c773b77127f04f37","name":"2021/2Q","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2021-07-01+created:<2021-09-30","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":460,"y":380,"wires":[["b3925c03a6535fae"]]},{"id":"f0713e0a6cea03cd","type":"debug","z":"c773b77127f04f37","name":"2023/1Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":100,"wires":[]},{"id":"bcb345b7ecf82749","type":"debug","z":"c773b77127f04f37","name":"2022/4Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":140,"wires":[]},{"id":"85ddda06eae24fc7","type":"debug","z":"c773b77127f04f37","name":"2022/3Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":180,"wires":[]},{"id":"0c2866566388e57c","type":"debug","z":"c773b77127f04f37","name":"2022/1Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":260,"wires":[]},{"id":"a290e8ae1506ac53","type":"debug","z":"c773b77127f04f37","name":"2020/4Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":460,"wires":[]},{"id":"0dbc8709701705ac","type":"debug","z":"c773b77127f04f37","name":"2021/1Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":420,"wires":[]},{"id":"b3925c03a6535fae","type":"debug","z":"c773b77127f04f37","name":"2021/2Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":380,"wires":[]},{"id":"d4ea2d6b40fc064c","type":"debug","z":"c773b77127f04f37","name":"2021/3Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":340,"wires":[]},{"id":"3d46b8e8fda4d0ad","type":"debug","z":"c773b77127f04f37","name":"2022/2Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":220,"wires":[]},{"id":"f9f8b3ae14d9be87","type":"debug","z":"c773b77127f04f37","name":"2021/4Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":300,"wires":[]},{"id":"1067c0b3007db4d0","type":"debug","z":"c773b77127f04f37","name":"2020/3Q","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.length","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":500,"wires":[]}]    
```

**1. Qiita APIを使用して、一定期間中に”競馬予測”の文字を含む記事が存在するかを検索する。**   
  
始めは月毎に件数を取得していたが対象数が少なかったため、集計期間を4半期毎に変更した。  
(1Q: 4/1-6/30, 2Q: 7/1-9/30, 3Q:10/1-12/31, 4Q:1/1-3/31 とした。) 
```javascript:http in ノード (2023/2Qの場合)
https://qiita.com/api/v2/items?page=1&per_page=50&query=body:競馬予測+created:>2023-07-01+created:<2023-09-30
```
  
  
**2. 検索結果の該当件数を出力する。**  

```javascript:debug ノード
msg.payload.length
```

##  分析結果・考察  
![hw1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3565590/c6e6e30a-706e-2f36-0d19-3d01dfc43ef1.png)  
  
2020/3Q-2023/2Qの"競馬予測"を含む記事の作成本数は季節的な傾向がありそう。  
3Q(10月-12月)に記事の本数が増えている。これはG1やG2レベルの有名なレースが秋~冬にかけて多いからだと考えられる。逆に夏は有名なレースが少ない。  
3Q(10月-12月)で記事の本数が増え、その反動で4Q(1月-3月)は本数が落ちている。よって、**記事を出す時期は来年の1月-3月に出すのが良さそう！**  

  
あと2021/1Qで平均の6-7倍ほど多く記事が書かれているのだが、なぜか検討がつかない...競馬に詳しい方教えてください...

## 反省点
・今回は検索回数を年間で一定としてしまったが、"競馬予測"と検索された回数を調べる必要があった。
・処理期のをループ構造にしたい、出力結果もcsv形式で落としたいが技術的に難しかった...   

  
## 参考サイト
https://qiita.com/kosuke0517lab/items/47c5ad862e74a489488d  

https://qiita.com/yonex/items/d3ade7c1ae9897536b28  


https://qiita.com/PmanRabbit/items/b4ffb0d46cfaeb73e1f6