private static void keepaLookupPrimeRecords() { var items = SalesBinderAPI.Inventory.Where(x => !string.IsNullOrEmpty(x.BarCode)) .Where(x => KeepaAPI.LastLookupTime(x.BarCode) == null); if (!items.Any()) { $"Have already tried to get keepa records for all items in inventory".ConsoleWriteLine(); } else { var ids = items.Take(100).Select(x => x.BarCode).Distinct().ToArray(); KeepaAPI.GetDetailsForIdentifiers(ids); } }
private static void keepaLookupRefreshCurrentInventory() { var items = SalesBinderAPI.Inventory.Where(x => x.Quantity > 0 && !string.IsNullOrEmpty(x.BarCode)) .Select(x => (Book: x, LastLookup: KeepaAPI.LastLookupTime(x.BarCode))) .Where(x => x.LastLookup == null || (DateTime.Now - x.LastLookup.Value).TotalDays > 1) .Select(x => x.Book) .ToArray(); // only want to do 100 as don't want to blow limits on keepa if (!items.Any()) { "Nothing to do - have been updated or attempted to be updated at least once in the last 24 hours" .ConsoleWriteLine(); } else { var ids = items.Take(100).Select(x => x.BarCode).Distinct().ToArray(); KeepaAPI.GetDetailsForIdentifiers(ids, forceRefresh_: true); } }