Skip to content

Commit

Permalink
Mobile Config filter Boosted Hexes (#801)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
michaeldjeffrey authored May 8, 2024
1 parent 90a7aa2 commit c9e98cb
Show file tree
Hide file tree
Showing 6 changed files with 310 additions and 205 deletions.
2 changes: 1 addition & 1 deletion boost_manager/src/activator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ where
manifest: RewardManifest,
) -> Result<()> {
// get latest boosted hexes info from mobile config
let boosted_hexes = BoostedHexes::get_all(&self.hex_boosting_client).await?;
let boosted_hexes = BoostedHexes::get_active(&self.hex_boosting_client).await?;

// get the rewards file from the manifest
let manifest_time = manifest.end_timestamp;
Expand Down
6 changes: 3 additions & 3 deletions boost_manager/tests/integrations/activator_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl TestContext {
async fn test_activated_hex_insert(pool: PgPool) -> anyhow::Result<()> {
let now = Utc::now();
let ctx = TestContext::setup(now)?;
let boosted_hexes = BoostedHexes::new(ctx.boosted_hexes);
let boosted_hexes = BoostedHexes::test_new_active(ctx.boosted_hexes)?;

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

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

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

0 comments on commit c9e98cb

Please sign in to comment.