public object Any(ClearCache request) { Cache.FlushAll(); PostServicesBase.PeriodicUpdateTableCaches(Db); PostServicesBase.ClearOrganizationCache(); Cache.FlushAll(); return("OK"); }
public object Any(HourlyTask request) { if (!request.Force) { return(new HourlyTaskResponse()); } var updatedTechIds = Db.ExecuteSql("UPDATE page_stats AS p SET ref_id = t.id FROM technology AS t WHERE t.slug = p.ref_slug and p.ref_type = 'tech' AND ref_id = 0"); var updatedStackIds = Db.ExecuteSql("UPDATE page_stats AS p SET ref_id = t.id FROM technology_stack AS t WHERE t.slug = p.ref_slug and p.ref_type = 'stack' AND ref_id = 0"); var techFavs = Db.Dictionary <long, long>("SELECT technology_id, count(*) FROM user_favorite_technology GROUP BY technology_id"); foreach (var techFav in techFavs) { Db.ExecuteSql("UPDATE page_stats SET fav_count = @favCount WHERE ref_id = @refId and ref_type = 'tech'", new { refId = techFav.Key, favCount = techFav.Value }); } var stackFavs = Db.Dictionary <long, long>("SELECT technology_stack_id, count(*) FROM user_favorite_technology_stack GROUP BY technology_stack_id"); foreach (var stackFav in stackFavs) { Db.ExecuteSql("UPDATE page_stats SET fav_count = @favCount WHERE ref_id = @refId and ref_type = 'stack'", new { refId = stackFav.Key, favCount = stackFav.Value }); } PostServicesBase.PeriodicUpdateTableCaches(Db); Any(new ClearCache()); return(new HourlyTaskResponse { Meta = new Dictionary <string, string> { { "updatedTechIds", updatedTechIds.ToString() }, { "updatedStackIds", updatedStackIds.ToString() }, { "techFavsCount", techFavs.Count.ToString() }, { "stackFavsCount", stackFavs.Count.ToString() }, } }); }