Git Product home page Git Product logo

hasoffers-kpi's People

Contributors

bloogrox avatar ijharulislam avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ijharulislam

hasoffers-kpi's Issues

Trigger model

take trigger get_cr (celery task) - https://github.com/bloogrox/hasoffers-kpi/blob/master/workers/trigger_handlers/tasks/min_cr_trigger.py
modify it, so it will listen to metric.loaded event.
it must receive event data
take trigger from database (Trigger model),
evaluate condition

{metric.value} {conditional operator} {threshold value}

Trigger model - is a condition

  • name
  • metric_key (enum: pacc, cr, ...)
  • operator (lt, gt)
  • active: bool

example

event.value > 0.05

here we have triggers
https://github.com/bloogrox/hasoffers-kpi/tree/master/workers/trigger_handlers/tasks
the problem is they are almost copy-paste

Estimation: 90 minutes

Action model

Action model

Action is a set of conditions and operations

fields

  • conditions (one-to-many)
  • operations (one-to-many)
  • active (bool)

Condition model

fields:

  • trigger
  • trigger_status

example:
trigger="min CR"
trigger_status="PROBLEM"

what means run given operation when "min CR" trigger is in a "PROBLEM" state

Operation model

fields

  • name

examples of operations:

  • send email to affiliate
  • send email to manager
  • send email to administrator
  • approve an offer for affiliate
  • reject affiliate from the offer

refactor to event driven flow

implement event flow

[worker: load metric] -> <event: metric.loaded> -> [worker: run trigger check] -> <event: trigger.checked> -> [worker: detect trigger event] -> <event: trigger.problem> -> [worker: run trigger actions]

Trigger Event model

trigger event is fired when trigger state is changed

trigger can have two states:

  • OK
  • PROBLEM

trigger state is calculated from trigger condition #8

trigger event publisher listens to trigger.checked event
is takes trigger status, and find previous trigger status from the log
if status is different, then trigger.event.ok or trigger.event.problem is emitted

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.