Skip to content

Commit c9e98cb

Browse files
Mobile Config filter Boosted Hexes (#801)
* Refactor to use BoostedHexes methods Making the internal member hexes private will make it easier to change the implementation when device type is introduced. * Add device type to boosted hex info * refactor metadata_db tests to make test clearer also makes it easier to add new tests * remove expired boosted hexes when streaming from db * ensure no tests are written with expired boosted hexes * optimize by computing end_ts in db query Thanks for the query help Brian! By precomputing the end timestamp of a boosted hex, we can not have to stream all the hexes out of the db just to throw them away. * fixup after rebase - remove unused imports - remove old refactor return types * make boosted hex test function more explicit If the expired check had been made a global check, the ability to use BoostedHexes for modified hexes would have broken at runtime. The attempt here is to make very explicit during testing how to meet the same contract as the database queries for boosted hexes. I think there are still some cracks, but we can narrow in on those as we find them. For now, I think naming test constructor functions is a good start.
1 parent 90a7aa2 commit c9e98cb

File tree

6 files changed

+310
-205
lines changed

6 files changed

+310
-205
lines changed

boost_manager/src/activator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ where
9696
manifest: RewardManifest,
9797
) -> Result<()> {
9898
// get latest boosted hexes info from mobile config
99-
let boosted_hexes = BoostedHexes::get_all(&self.hex_boosting_client).await?;
99+
let boosted_hexes = BoostedHexes::get_active(&self.hex_boosting_client).await?;
100100

101101
// get the rewards file from the manifest
102102
let manifest_time = manifest.end_timestamp;

boost_manager/tests/integrations/activator_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl TestContext {
8787
async fn test_activated_hex_insert(pool: PgPool) -> anyhow::Result<()> {
8888
let now = Utc::now();
8989
let ctx = TestContext::setup(now)?;
90-
let boosted_hexes = BoostedHexes::new(ctx.boosted_hexes);
90+
let boosted_hexes = BoostedHexes::test_new_active(ctx.boosted_hexes)?;
9191

9292
// test a boosted hex derived from radio rewards
9393
// with a non set start date, will result in a row being
@@ -117,7 +117,7 @@ async fn test_activated_hex_insert(pool: PgPool) -> anyhow::Result<()> {
117117
async fn test_activated_hex_no_insert(pool: PgPool) -> anyhow::Result<()> {
118118
let now = Utc::now();
119119
let ctx = TestContext::setup(now)?;
120-
let boosted_hexes = BoostedHexes::new(ctx.boosted_hexes);
120+
let boosted_hexes = BoostedHexes::test_new_active(ctx.boosted_hexes)?;
121121

122122
// test a boosted hex derived from radio rewards
123123
// with an active start date, will result in no row being
@@ -143,7 +143,7 @@ async fn test_activated_hex_no_insert(pool: PgPool) -> anyhow::Result<()> {
143143
async fn test_activated_dup_hex_insert(pool: PgPool) -> anyhow::Result<()> {
144144
let now = Utc::now().with_second(0).unwrap();
145145
let ctx = TestContext::setup(now)?;
146-
let boosted_hexes = BoostedHexes::new(ctx.boosted_hexes);
146+
let boosted_hexes = BoostedHexes::test_new_active(ctx.boosted_hexes)?;
147147

148148
// test with DUPLICATE boosted hexes derived from radio rewards
149149
// with a non set start date, will result in a single row being

0 commit comments

Comments
 (0)