Code Monkey home page Code Monkey logo

campaign-ads-discrepancies's Introduction

CampaignAdsDiscrepancies

Build Status

Goal

Find discrepancies between campaigns (local ads) and remote ads.

Task background

We publish our jobs to different marketing sources. To keep track of where the particular job is published, we create Campaign entity in database. Campaigns are periodically synchronized with 3rd party Ad Service.

Campaign properties:

  • id
  • job_id
  • status: one of [active, paused, deleted]
  • external_reference: corresponds to Ad’s ‘reference’
  • ad_description: text description of an Ad

Due to various types of failures (Ad Service unavailability, errors in campaign details etc.) local Campaigns can fall out of sync with Ad Service. So we need a way to detect discrepancies between local and remote state.

Assumptions

  • Just for sake of simplicity, No DB used, but its loading data from a CSV file from db folder here.
  • I have created various classes to follow the OOPs concept. CampaignAdsDiscrepancies::DiscrepanciesServices::DiscrepanciesDetector class is a high level class which is responsible to test overall functionality. Internally, this class calls all other classes and objects and return you the final result. CampaignAdsDiscrepancies::DiscrepanciesServices::DiscrepanciesDetector is only for better clarity and understanding.
  • Not handling all kinds of external API errors.

Output Format

Discrepancies Not Found

[]

Discrepancies Found

[
  {
    :remote_reference => "2",
    :discrepancies => [
      {
        "status" => {
          :remote => "disabled",
          :local => "paused"
        }
      }
    ]
  },
  {
    :remote_reference => "3",
    :discrepancies => [
      {
        "status" => {
          :remote => "enabled",
          :local => "deleted"
        },
        "description" => {
          :remote => "Description for campaign 13",
          :local => "Description for campaign 14"
        }
      }
    ]
  }
]

Running Specs

Run bundle exec rspec spec from command line.

Testing

Run bundle exec rake console to load entire application in IRB console. In IRB console, run

CampaignAdsDiscrepancies::DiscrepanciesServices::DiscrepanciesDetector.call

It will provide you all discrepancies found.

campaign-ads-discrepancies's People

Contributors

neerajkumar avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.