Ma Suhyeon

Fix some omissions

...@@ -75,6 +75,7 @@ func NewApp(config Config) *App { ...@@ -75,6 +75,7 @@ func NewApp(config Config) *App {
75 extraction.DELETE("/messages/:id", app.DeleteMessage) 75 extraction.DELETE("/messages/:id", app.DeleteMessage)
76 76
77 extraction.GET("/calls/analyses", app.GetCallsAnalyses) 77 extraction.GET("/calls/analyses", app.GetCallsAnalyses)
78 + extraction.GET("/regions", app.GetRegions)
78 79
79 extraction.GET("/apps/analyses", app.GetAppsAnalyses) 80 extraction.GET("/apps/analyses", app.GetAppsAnalyses)
80 extraction.POST("/apps/analyses", app.PostAppAnalysis) 81 extraction.POST("/apps/analyses", app.PostAppAnalysis)
......
...@@ -403,6 +403,25 @@ func (app *App) GetDailyContacts(c echo.Context) error { ...@@ -403,6 +403,25 @@ func (app *App) GetDailyContacts(c echo.Context) error {
403 return c.JSON(http.StatusOK, result) 403 return c.JSON(http.StatusOK, result)
404 } 404 }
405 405
406 +type RegionStats struct {
407 + Region string `json:"region" db:"region"`
408 + Incoming int `json:"incoming" db:"incoming"`
409 + Outgoing int `json:"outgoing" db:"outgoing"`
410 + Duration int `json:"duration" db:"duration"`
411 + Receive int `json:"receive" db:"receive"`
412 + Send int `json:"send" db:"send"`
413 +}
414 +
415 +func (app *App) GetRegions(c echo.Context) error {
416 + regions := []RegionStats{}
417 + query := "SELECT * FROM region_stats WHERE `extraction_no`=?"
418 + if err := app.db.Unsafe().Select(&regions, query, c.Param("no")); err != nil {
419 + return err
420 + }
421 +
422 + return c.JSON(http.StatusOK, regions)
423 +}
424 +
406 func NormalizeNumber(number string) string { 425 func NormalizeNumber(number string) string {
407 if len(number) > 0 && number[0] == '+' { 426 if len(number) > 0 && number[0] == '+' {
408 return number 427 return number
......
...@@ -183,5 +183,5 @@ func (app *App) PostExtractions(c echo.Context) error { ...@@ -183,5 +183,5 @@ func (app *App) PostExtractions(c echo.Context) error {
183 183
184 exec.Command(app.Config.PythonBin, "process.py", fmt.Sprint(extNo)).Run() 184 exec.Command(app.Config.PythonBin, "process.py", fmt.Sprint(extNo)).Run()
185 185
186 - return c.NoContent(http.StatusNoContent) 186 + return c.JSON(http.StatusOK, echo.Map{"extraction_no": extNo})
187 } 187 }
......