Ma Suhyeon

Fix some omissions

......@@ -75,6 +75,7 @@ func NewApp(config Config) *App {
extraction.DELETE("/messages/:id", app.DeleteMessage)
extraction.GET("/calls/analyses", app.GetCallsAnalyses)
extraction.GET("/regions", app.GetRegions)
extraction.GET("/apps/analyses", app.GetAppsAnalyses)
extraction.POST("/apps/analyses", app.PostAppAnalysis)
......
......@@ -403,6 +403,25 @@ func (app *App) GetDailyContacts(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}
type RegionStats struct {
Region string `json:"region" db:"region"`
Incoming int `json:"incoming" db:"incoming"`
Outgoing int `json:"outgoing" db:"outgoing"`
Duration int `json:"duration" db:"duration"`
Receive int `json:"receive" db:"receive"`
Send int `json:"send" db:"send"`
}
func (app *App) GetRegions(c echo.Context) error {
regions := []RegionStats{}
query := "SELECT * FROM region_stats WHERE `extraction_no`=?"
if err := app.db.Unsafe().Select(&regions, query, c.Param("no")); err != nil {
return err
}
return c.JSON(http.StatusOK, regions)
}
func NormalizeNumber(number string) string {
if len(number) > 0 && number[0] == '+' {
return number
......
......@@ -183,5 +183,5 @@ func (app *App) PostExtractions(c echo.Context) error {
exec.Command(app.Config.PythonBin, "process.py", fmt.Sprint(extNo)).Run()
return c.NoContent(http.StatusNoContent)
return c.JSON(http.StatusOK, echo.Map{"extraction_no": extNo})
}
......