package test

import (
	"fmt"
	"github.com/kataras/iris/v12"
	"main/database"
	"main/model"
)

func TestSend(ctx iris.Context) {
	var d []data
	db := database.GetInstance().GetMysqlDb()
	//query := db.Distinct("ip").Find(&model.Logs{})
	//query.Select("logs.ip,ips_locations.location").Where("ips_locations.location is null").Joins("left join ips_locations on logs.ip=ip_locations.ip").Scan(&d)
	//db.Model(&model.IpsLocation{}).Select("a.ip,ips_locations.location").Where("ips_locations.location is null").Joins("right join (?) a on a.ip=ips_locations.ip", query).Scan(&d)
	//query.Model(&model.IpsLocation{}).Select("logs.ip,ips_locations.location").Where("ips_locations.location is null").Joins("left join ips_locations on logs.ip=ips_locations.ip").Scan(&d)
	db.Model(&model.Logs{}).Distinct("logs.ip", "ips_locations.location").Where("ips_locations.location is null").Joins("left join ips_locations on logs.ip=ips_locations.ip").Scan(&d)
	fmt.Println(len(d))
}

type data struct {
	IP       string `json:"ip"`
	Location string `json:"location"`
}
