Giter Club home page Giter Club logo

campaigner's People

Stargazers

 avatar

Watchers

 avatar

campaigner's Issues

7. Tests

The Test Process

Preparation

Generate 1000 campaigns with the “Campaign generator”, X=50,Y=10,Z=1000, the output file is downloadable.
Import the above data to the server app with data struct or database to make the searching provision ready.

5. Endpoint: matching campaign by user info

Endpoint:

[POST] http://myhost:3000/search

User story:

Create an API for campaign searching with user info.
The request will POST a user info, and return the searching result.

Input:

Input should be the same as output of the User Generator endpoint: #2

Definitions:

  • Targeted User: If all targets of the campaign can be found in an user's profile, and the user’s profile attribute value can be found in the list of the campaign target attri_list.

Tasks:

  • create endpoint
  • reuse matching business logic

2. User data generator and endpoint

Endpoint:

[GET] http://myhost:3000/user

User story:

Create a API for user generation.
This endpoint will return a user info defined as following.
There’s a counter for request (starts with 0), each request will increase the counter by 1.
Create a function to generate the following user info when it receive a request.

	"user": “u”+counter,
	"profile":[
		"attr_A" : "A" + random(200)
		"attr_B" : "B" + random(200)
		...
	]

The length of the profile will be increased by 1 everytime when a new user is generated. The attribute name and value contained in the profile need to follow the alphabet order, such as [“attr_A” : “A1”], [“attr_B” : “B23”], etc. When the profile length reaches its maximum length of 26, it gets reset to 1 again, which means it only contains “attr_A”.

Output examples:

The 1st user

{
	"user": “u1”,
	"profile":[
		"attr_A" : "A1"
	]
}

The 3rd user

{
	"user": “u3”,
	"profile":[
		"attr_A" : "A23"
		"attr_B" : "B132"
		"attr_C" : "C45"
	]
}

The 27th user

{
	"user": “u27”,
	"profile":[
		"attr_A" : "A109"
	]
}

The 28th user

{
	"user": “u28”,
	"profile":[
		"attr_A" : "A109"
		"attr_B" : "B87"
	]
}

1. Campaign Data Generator and endpoint

Endpoint:

[GET] http://myhost:3000/campaign?x={number}&y={number}&z={number}

Params:

The generator has parameters: X (X <= 100) , Y (Y =< 26), Z (Z <= 10000)

User Story:

Generate Z number of campaigns, each campaign has a target list (length is random and less than Y).
The target has an attribution list (length is random and less than X).
Each campaign has an offer price, which is randomly generated.

Output:

Here is a sample output JSON file:

[
	{
		"compaign_name": "campaign870",
		"price":3.25
		"target_list" : [
			{"target":"attr_A", "attr_list":["A0",...,"A99"]},
			{"target":"attr_B", "attr_list":["B0",...,"B36"]},
			...
		]
	},
	...
]

Tasks:

  • Create a campaign generator logic
  • Cover generator logic with unit tests

6. Auto generate user and search

Endpoint:

GET http://myhost:3000/search_auto

User Story:

The request for the search API will trigger the function to create a user in step 2 and pass the user to the search function, if the user is a “Targeted User”, then Find the the campaign that has the HIGHEST price, otherwise return “none”.

4. Campaign matcher logic

Create a matcher logic that will search through the data persisted in the application using #3 and return the campaign that will best fit to the input data.

Input data of the matcher should be the user profile data, same as generated here #2

User story

Assume there’s 2 campaigns:

{
		"compaign_name": "campaign1",
		"price":0.25
		"target_list" : [
			{"target":"attr_A", "attr_list":["A0",...,"A9"]},
			{"target":"attr_B", "attr_list":["B0",...,"B16"]},
		]
},
{
		"compaign_name": "campaign2",
		"price":0.35
		"target_list" : [
			{"target":"attr_A", "attr_list":["A0",...,"A19"]},
		]
}

To help you understanding the abstract model, let’s assume some campaign targeting {attr_A = “country”, attr_list=[“US”,“UK”,...]}, {attr_B= “hobby”, attr_list = [“football”,“fishing”,“sports”]}.

Matching cases:
image

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.