/* func GetFacebookPostLikes(id string, since time.Time, until time.Time)(data []string, timestamp []string){ fmt.Println(id) values := db.ReadValues("universum","FacebookStreamAggregated",id) columns := db.ReadColumns("universum","FacebookStreamAggregated",id) data, timestamp = GetMetricWindow("likes_count", values, columns, since, until) return } */ func GetPages(brandname string) (pages []string) { values := db.Read("universum", "manualEntry", brandname) fmt.Println("wowowo") if len(values) > 0 { split := strings.Split(values[0], "\n") for i := range split { split2 := strings.Split(split[i], "//") if len(split2) > 3 { pages = append(pages, split2[1], split2[0], split2[3], split2[2]) } } } return }
func GetFirstLinkedinId(brandname string) (id string) { id = "1694" values := db.Read("universum", "manualEntry", brandname) fmt.Println("wowowo") if len(values) > 0 { split := strings.Split(values[0], "\n") for i := range split { split2 := strings.Split(split[i], "//") if len(split2) > 3 { if split2[0] == "IN:" { id = split2[1] } } } } return }
//add error catching here. func (r *UniversumController) Read(brand string, ctx context.Context) error { fmt.Println("rest") query := ctx.HttpRequest().URL.RawQuery //metric_name := GetQueryValue("name",query) since_str := GetQueryValue("since", query) const shortForm = "2006-Jan-02" since, _ := time.Parse(shortForm, since_str) until_str := GetQueryValue("until", query) until, _ := time.Parse(shortForm, until_str) resolution := "day" key := GetQueryValue("apikey", query) fmt.Println("the api key is " + key) user_id := db.Read("universum", "apikeys", key) if len(user_id) < 1 { errObject := "unverified api key" return goweb.API.RespondWithError(ctx, 500, errObject) } if brand == "ranking" { ranking := new(RankingData) ranking.Type = brand ranking.Brands, ranking.Change = GetMetrics(brand, query, since, until, resolution) return goweb.API.RespondWithData(ctx, ranking) } data := new(Data) data.Brand = brand data.Metrics, data.TimeStamp = GetMetrics(brand, query, since, until, resolution) fmt.Println("booyay") return goweb.API.RespondWithData(ctx, data) }