mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-30 21:30:05 +00:00 
			
		
		
		
	Don't continue to refresh level 2 data if no data is present
This commit is contained in:
		
							parent
							
								
									70b8f78eb5
								
							
						
					
					
						commit
						5cfab59977
					
				
					 4 changed files with 21 additions and 10 deletions
				
			
		|  | @ -304,7 +304,7 @@ void RadarProductManagerImpl::RefreshLevel2Data() | ||||||
|    util::async( |    util::async( | ||||||
|       [&]() |       [&]() | ||||||
|       { |       { | ||||||
|          size_t newObjects = level2DataProvider_->Refresh(); |          auto [newObjects, totalObjects] = level2DataProvider_->Refresh(); | ||||||
| 
 | 
 | ||||||
|          std::chrono::milliseconds interval = kRetryInterval_; |          std::chrono::milliseconds interval = kRetryInterval_; | ||||||
| 
 | 
 | ||||||
|  | @ -325,11 +325,17 @@ void RadarProductManagerImpl::RefreshLevel2Data() | ||||||
| 
 | 
 | ||||||
|             emit self_->NewLevel2DataAvailable(latestTime); |             emit self_->NewLevel2DataAvailable(latestTime); | ||||||
|          } |          } | ||||||
|  |          else if (level2DataRefreshEnabled_ && totalObjects == 0) | ||||||
|  |          { | ||||||
|  |             logger_->info("No level 2 data found, disabling refresh"); | ||||||
| 
 | 
 | ||||||
|          std::unique_lock lock(level2DataRefreshTimerMutex_); |             level2DataRefreshEnabled_ = false; | ||||||
|  |          } | ||||||
| 
 | 
 | ||||||
|          if (level2DataRefreshEnabled_) |          if (level2DataRefreshEnabled_) | ||||||
|          { |          { | ||||||
|  |             std::unique_lock lock(level2DataRefreshTimerMutex_); | ||||||
|  | 
 | ||||||
|             logger_->debug( |             logger_->debug( | ||||||
|                "Scheduled refresh in {:%M:%S}", |                "Scheduled refresh in {:%M:%S}", | ||||||
|                std::chrono::duration_cast<std::chrono::seconds>(interval)); |                std::chrono::duration_cast<std::chrono::seconds>(interval)); | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ public: | ||||||
|    std::pair<size_t, size_t> |    std::pair<size_t, size_t> | ||||||
|    ListObjects(std::chrono::system_clock::time_point date); |    ListObjects(std::chrono::system_clock::time_point date); | ||||||
|    std::shared_ptr<wsr88d::NexradFile> LoadObjectByKey(const std::string& key); |    std::shared_ptr<wsr88d::NexradFile> LoadObjectByKey(const std::string& key); | ||||||
|    size_t                              Refresh(); |    std::pair<size_t, size_t>           Refresh(); | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
|    virtual std::string |    virtual std::string | ||||||
|  |  | ||||||
|  | @ -84,9 +84,11 @@ public: | ||||||
|     * no objects have been added to the cache for the current date, the previous |     * no objects have been added to the cache for the current date, the previous | ||||||
|     * date is also queried for data. |     * date is also queried for data. | ||||||
|     * |     * | ||||||
|     * @return New objects found |     * @return - New objects found | ||||||
|  |     *         - Total objects found | ||||||
|     */ |     */ | ||||||
|    virtual size_t Refresh() = 0; | 
 | ||||||
|  |    virtual std::pair<size_t, size_t> Refresh() = 0; | ||||||
| 
 | 
 | ||||||
|    /**
 |    /**
 | ||||||
|     * Convert the object key to a time point. |     * Convert the object key to a time point. | ||||||
|  |  | ||||||
|  | @ -237,7 +237,7 @@ AwsNexradDataProvider::LoadObjectByKey(const std::string& key) | ||||||
|    return nexradFile; |    return nexradFile; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| size_t AwsNexradDataProvider::Refresh() | std::pair<size_t, size_t> AwsNexradDataProvider::Refresh() | ||||||
| { | { | ||||||
|    using namespace std::chrono; |    using namespace std::chrono; | ||||||
| 
 | 
 | ||||||
|  | @ -251,14 +251,16 @@ size_t AwsNexradDataProvider::Refresh() | ||||||
| 
 | 
 | ||||||
|    std::unique_lock lock(refreshMutex); |    std::unique_lock lock(refreshMutex); | ||||||
| 
 | 
 | ||||||
|    size_t totalNewObjects = 0; |    size_t allNewObjects   = 0; | ||||||
|  |    size_t allTotalObjects = 0; | ||||||
| 
 | 
 | ||||||
|    // If we haven't gotten any objects from today, first list objects for
 |    // If we haven't gotten any objects from today, first list objects for
 | ||||||
|    // yesterday, to ensure we haven't missed any objects near midnight
 |    // yesterday, to ensure we haven't missed any objects near midnight
 | ||||||
|    if (refreshDate < today) |    if (refreshDate < today) | ||||||
|    { |    { | ||||||
|       auto [newObjects, totalObjects] = ListObjects(yesterday); |       auto [newObjects, totalObjects] = ListObjects(yesterday); | ||||||
|       totalNewObjects                 = newObjects; |       allNewObjects                   = newObjects; | ||||||
|  |       allTotalObjects                 = totalObjects; | ||||||
|       if (totalObjects > 0) |       if (totalObjects > 0) | ||||||
|       { |       { | ||||||
|          refreshDate = yesterday; |          refreshDate = yesterday; | ||||||
|  | @ -266,13 +268,14 @@ size_t AwsNexradDataProvider::Refresh() | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    auto [newObjects, totalObjects] = ListObjects(today); |    auto [newObjects, totalObjects] = ListObjects(today); | ||||||
|    totalNewObjects += newObjects; |    allNewObjects += newObjects; | ||||||
|  |    allTotalObjects += totalObjects; | ||||||
|    if (totalObjects > 0) |    if (totalObjects > 0) | ||||||
|    { |    { | ||||||
|       refreshDate = today; |       refreshDate = today; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    return totalNewObjects; |    return std::make_pair(allNewObjects, allTotalObjects); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AwsNexradDataProvider::Impl::PruneObjects() | void AwsNexradDataProvider::Impl::PruneObjects() | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat