hasoffers-kpi's People
Forkers
ijharulislamhasoffers-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
setup circle ci->heroku deployment
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
fix all flake warnings
run
flake8
and fix
Estimation: 60 minutes
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]
add "reason" to unapprove log
add a reason
field to the model stats.models.UnapproveLog
,
explain why was affiliate unapproved
example
due to pacc: -20$
move sensitive data to env var - network title
setup celery_pubsub
install this fork
git+https://github.com/bloogrox/celery-pubsub@import-fix
Metric worker should fire metric.loaded
event
{
key:
value:
affiliate_id:
offer_id:
}
later we'll implement trigger
worker who will subscribe to it
Estimate: 40 minutes
some models write to mongodb
unapprove log
metric log
threshold checks log
trigger events log
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
implement Threshold entity with priority levels
Entity: Threshold
- trigger_id
- value
- entity_type
- ref_id
Entity Type (starting from highest priority)
- Affiliate
- Offer
- Category
- Global
Then take appropriate threshold and use it in triggers
https://github.com/bloogrox/hasoffers-kpi/blob/master/workers/trigger_handlers/tasks/max_cr_trigger.py#L13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.