From 253781f87c1653ee203ba3e7bf340747b894140d Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Thu, 10 Apr 2014 18:55:07 -0700 Subject: DD-16 : Implement sort by stock count in merketplace --- indra/newview/llfolderviewmodelinventory.cpp | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfolderviewmodelinventory.cpp') diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index aac3a41b9e..c31b40b179 100755 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -27,6 +27,7 @@ #include "llviewerprecompiledheaders.h" #include "llfolderviewmodelinventory.h" #include "llinventorymodelbackgroundfetch.h" +#include "llinventoryfunctions.h" #include "llinventorypanel.h" #include "lltooldraganddrop.h" #include "llfavoritesbar.h" @@ -269,7 +270,7 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, // We sort by name if we aren't sorting by date // OR if these are folders and we are sorting folders by name. - bool by_name = (!mByDate || (mFoldersByName && (a->getSortGroup() != SG_ITEM))); + bool by_name = ((!mByDate || (mFoldersByName && (a->getSortGroup() != SG_ITEM))) && !mFoldersByWeight); if (a->getSortGroup() != b->getSortGroup()) { @@ -301,6 +302,35 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, return (compare < 0); } } + else if (mFoldersByWeight) + { + S32 weight_a = compute_stock_count(a->getUUID()); + S32 weight_b = compute_stock_count(b->getUUID()); + if ((weight_a != -1) || (weight_b != -1)) + { + llinfos << "Merov : sort by weight, a = " << a->getName() << ", " << weight_a << ", b = " << b->getName() << ", " << weight_b << llendl; + } + if (weight_a == weight_b) + { + // Equal weight -> use alphabetical order + return (LLStringUtil::compareDict(a->getDisplayName(), b->getDisplayName()) < 0); + } + else if (weight_a == -1) + { + // No weight -> move a at the end of the list + return false; + } + else if (weight_b == -1) + { + // No weight -> move b at the end of the list + return true; + } + else + { + // Lighter is first (sorted in increasing order of weight) + return (weight_a < weight_b); + } + } else { time_t first_create = a->getCreationDate(); -- cgit v1.3 From fd426bafb6616491b8929ee357a5b2d40e123607 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Sat, 31 May 2014 19:19:20 -0700 Subject: DD-92 : Clear llinfos compilation warning and similar --- indra/newview/llfloatermarketplacelistings.cpp | 9 +++------ indra/newview/llfolderviewmodelinventory.cpp | 4 ---- indra/newview/llinventoryfunctions.cpp | 6 +++--- indra/newview/lllogchat.cpp | 1 - 4 files changed, 6 insertions(+), 14 deletions(-) (limited to 'indra/newview/llfolderviewmodelinventory.cpp') diff --git a/indra/newview/llfloatermarketplacelistings.cpp b/indra/newview/llfloatermarketplacelistings.cpp index ba519c8899..88abd9ff9d 100755 --- a/indra/newview/llfloatermarketplacelistings.cpp +++ b/indra/newview/llfloatermarketplacelistings.cpp @@ -222,8 +222,7 @@ BOOL LLFloaterMarketplaceListings::postBuild() mCategoryAddedObserver = new LLMarketplaceListingsAddedObserver(this); gInventory.addObserver(mCategoryAddedObserver); - // Merov : Debug : fetch aggressively so we can create test data right onOpen() - llinfos << "Merov : postBuild, do fetchContent() ahead of time" << llendl; + // Debug : fetch aggressively so we can create test data right onOpen() fetchContents(); return TRUE; @@ -276,8 +275,7 @@ void LLFloaterMarketplaceListings::setup() if (marketplacelistings_id.isNull()) { // We should never get there unless the inventory fails badly - llinfos << "Merov : Inventory problem: failure to create the marketplace listings folder for a merchant!" << llendl; - llerrs << "Inventory problem: failure to create the marketplace listings folder for a merchant!" << llendl; + LL_ERRS("SLM") << "Inventory problem: failure to create the marketplace listings folder for a merchant!" << LL_ENDL; return; } @@ -287,8 +285,7 @@ void LLFloaterMarketplaceListings::setup() if (marketplacelistings_id == mRootFolderId) { - llinfos << "Merov : Inventory warning: Marketplace listings folder already set" << llendl; - llwarns << "Inventory warning: Marketplace listings folder already set" << llendl; + LL_WARNS("SLM") << "Inventory warning: Marketplace listings folder already set" << LL_ENDL; return; } mRootFolderId = marketplacelistings_id; diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index f911b12b55..263e6655f6 100755 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -306,10 +306,6 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, { S32 weight_a = compute_stock_count(a->getUUID()); S32 weight_b = compute_stock_count(b->getUUID()); - if ((weight_a != -1) || (weight_b != -1)) - { - llinfos << "Merov : sort by weight, a = " << a->getName() << ", " << weight_a << ", b = " << b->getName() << ", " << weight_b << llendl; - } if (weight_a == weight_b) { // Equal weight -> use alphabetical order diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index baa2a08933..5dc2385f04 100755 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -166,7 +166,7 @@ void update_marketplace_category(const LLUUID& cur_uuid) if (version_folder_uuid.notNull() && !gInventory.isObjectDescendentOf(version_folder_uuid, listing_uuid)) { // *TODO : Confirm with Producer that this is what we want to happen in that case! - llinfos << "Merov : Unlist as the version folder is not under the listing folder anymore!!" << llendl; + LL_INFOS("SLM") << "Unlist as the version folder is not under the listing folder anymore!!" << LL_ENDL; LLMarketplaceData::instance().setVersionFolder(listing_uuid, LLUUID::null); LLMarketplaceData::instance().activateListing(listing_uuid, false); } @@ -180,7 +180,7 @@ void update_marketplace_category(const LLUUID& cur_uuid) if (LLMarketplaceData::instance().isListed(cur_uuid)) { // *TODO : Confirm with Producer that this is what we want to happen in that case! - llinfos << "Merov : Disassociate as the listing folder is not under the marketplace folder anymore!!" << llendl; + LL_INFOS("SLM") << "Disassociate as the listing folder is not under the marketplace folder anymore!!" << LL_ENDL; LLMarketplaceData::instance().clearListing(cur_uuid); } } @@ -1008,7 +1008,7 @@ int get_folder_path_length(const LLUUID& ancestor_id, const LLUUID& descendant_i category = gInventory.getCategory(parent_id); } - llwarns << "get_folder_path_length() couldn't trace a path from the descendant to the ancestor" << llendl; + LL_WARNS("SLM") << "get_folder_path_length() couldn't trace a path from the descendant to the ancestor" << LL_ENDL; return -1; } diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 06e517a861..0bfcea41b7 100755 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -1022,7 +1022,6 @@ void LLLoadHistoryThread::run() { loadHistory(mFileName, mMessages, mLoadParams); int count = mMessages->size(); - llinfos << "mMessages->size(): " << count << llendl; setFinished(); } } -- cgit v1.3 From 637e096d5718d0a174b5383aa29e3480edd734ea Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Mon, 13 Apr 2015 15:29:56 -0700 Subject: DD-388 : More resilient way of reacting to not evaluated stock count throughout marketplace handling --- indra/newview/llfolderviewmodelinventory.cpp | 8 +++---- indra/newview/llinventorybridge.cpp | 14 ++++++++--- indra/newview/llinventoryfunctions.cpp | 18 +++++++------- indra/newview/llinventoryfunctions.h | 4 ++++ indra/newview/llmarketplacefunctions.cpp | 36 ++++++++++++++++++++++++++-- 5 files changed, 63 insertions(+), 17 deletions(-) (limited to 'indra/newview/llfolderviewmodelinventory.cpp') diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index 8c360befc3..44eda4d6c0 100755 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -319,14 +319,14 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, // Equal weight -> use alphabetical order return (LLStringUtil::compareDict(a->getDisplayName(), b->getDisplayName()) < 0); } - else if (weight_a == -1) + else if (weight_a == COMPUTE_STOCK_INFINITE) { - // No weight -> move a at the end of the list + // No stock -> move a at the end of the list return false; } - else if (weight_b == -1) + else if (weight_b == COMPUTE_STOCK_INFINITE) { - // No weight -> move b at the end of the list + // No stock -> move b at the end of the list return true; } else diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index df07c06467..6d92a05102 100755 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4261,15 +4261,23 @@ std::string LLMarketplaceFolderBridge::getLabelSuffix() const { suffix += " (" + LLTrans::getString("MarketplaceNoStock") + ")"; } - else if (stock_count != -1) + else if (stock_count != COMPUTE_STOCK_INFINITE) { if (getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK) { - suffix += " (" + LLTrans::getString("MarketplaceStock") + "=" + llformat("%d", stock_count) + ")"; + suffix += " (" + LLTrans::getString("MarketplaceStock"); } else { - suffix += " (" + LLTrans::getString("MarketplaceMax") + "=" + llformat("%d", stock_count) + ")"; + suffix += " (" + LLTrans::getString("MarketplaceMax"); + } + if (stock_count == COMPUTE_STOCK_NOT_EVALUATED) + { + suffix += "=" + LLTrans::getString("MarketplaceUpdating") + ")"; + } + else + { + suffix += "=" + llformat("%d", stock_count) + ")"; } } // Add updating suffix diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 135b6f2f17..9e88acdbd7 100755 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -1020,14 +1020,15 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) if (!cat) { // Not a category so no stock count to speak of - return -1; + return COMPUTE_STOCK_INFINITE; } if (cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK) { if (cat->getVersion() == LLViewerInventoryCategory::VERSION_UNKNOWN) { // If the folder is not completely fetched, we do not want to return any confusing value that could lead to unlisting - return -1; + // "COMPUTE_STOCK_NOT_EVALUATED" denotes that a stock folder has a count that cannot be evaluated at this time (folder not up to date) + return COMPUTE_STOCK_NOT_EVALUATED; } // Note: stock folders are *not* supposed to have nested subfolders so we stop recursion here but we count only items (subfolders will be ignored) // Note: we *always* give a stock count for stock folders, it's useful even if the listing is unassociated @@ -1047,7 +1048,7 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) if (!LLMarketplaceData::instance().isListed(listing_uuid)) { // If not listed, the notion of stock is meaningless so it won't be computed for any level - return -1; + return COMPUTE_STOCK_INFINITE; } LLUUID version_folder_uuid = LLMarketplaceData::instance().getVersionFolder(listing_uuid); @@ -1062,7 +1063,7 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) else { // If there's no version folder associated, the notion of stock count has no meaning - return -1; + return COMPUTE_STOCK_INFINITE; } } else if (depth == 2) @@ -1070,18 +1071,19 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) if (version_folder_uuid.notNull() && (version_folder_uuid != cat_uuid)) { // If there is a version folder but we're not it, our stock count is meaningless - return -1; + return COMPUTE_STOCK_INFINITE; } } } // In all other cases, the stock count is the min of stock folders count found in the descendents + // "COMPUTE_STOCK_NOT_EVALUATED" denotes that a stock folder in the hierarchy has a count that cannot be evaluated at this time (folder not up to date) LLInventoryModel::cat_array_t* cat_array; LLInventoryModel::item_array_t* item_array; gInventory.getDirectDescendentsOf(cat_uuid,cat_array,item_array); - // "-1" denotes a folder that doesn't countain any stock folders in its descendents - S32 curr_count = -1; + // "COMPUTE_STOCK_INFINITE" denotes a folder that doesn't countain any stock folders in its descendents + S32 curr_count = COMPUTE_STOCK_INFINITE; // Note: marketplace listings have a maximum depth nesting of 4 LLInventoryModel::cat_array_t cat_array_copy = *cat_array; @@ -1089,7 +1091,7 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) { LLInventoryCategory* category = *iter; S32 count = compute_stock_count(category->getUUID(), true); - if ((curr_count == -1) || ((count != -1) && (count < curr_count))) + if ((curr_count == COMPUTE_STOCK_INFINITE) || ((count != COMPUTE_STOCK_INFINITE) && (count < curr_count))) { curr_count = count; } diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 4f4a64a7f9..687aa57d7f 100755 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -32,6 +32,10 @@ #include "llinventory.h" #include "llwearabletype.h" +// compute_stock_count() return error code +const S32 COMPUTE_STOCK_INFINITE = -1; +const S32 COMPUTE_STOCK_NOT_EVALUATED = -2; + /******************************************************************************** ** ** ** MISCELLANEOUS GLOBAL FUNCTIONS diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index de3bd35de0..88a05c1e7f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1426,6 +1426,14 @@ bool LLMarketplaceData::createListing(const LLUUID& folder_id) { count = compute_stock_count(version_id, true); } + + // Validate the count on hand + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) at creation time + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing creation request to SLM createSLMListing(folder_id, version_id, count); @@ -1517,7 +1525,13 @@ bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) // Also update the count on hand S32 count = compute_stock_count(folder_id); - + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated locally, we should not change that SLM value + // We are assuming that this issue is local and should not modify server side values + count = getCountOnHand(listing_uuid); + } + // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_uuid, activate, count); @@ -1547,6 +1561,12 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& // Also update the count on hand S32 count = compute_stock_count(version_id); + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) when resetting the version folder + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_id, is_listed, count); @@ -1569,11 +1589,16 @@ bool LLMarketplaceData::updateCountOnHand(const LLUUID& folder_id) // Compute the new count on hand S32 count = compute_stock_count(folder_id); - if (getCountOnHand(listing_uuid) == count) + if (count == getCountOnHand(listing_uuid)) { // If count on hand is unchanged, no point spamming SLM with an update return true; } + else if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If local count on hand is not known at that point, do *not* force an update to SLM + return false; + } // Get the unchanged values bool is_listed = getActivationState(listing_uuid); @@ -1611,6 +1636,13 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& { count = compute_stock_count(version_id, true); // Use the stock count of the new listing } + // Validate the count on hand + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) at reassign time + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing update request to SLM updateSLMListing(folder_id, listing_id, version_id, is_listed, count); -- cgit v1.3