-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem.txt
More file actions
50 lines (33 loc) · 1.61 KB
/
Problem.txt
File metadata and controls
50 lines (33 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
----------------------------------------------------
PYTHON
----------------------------------------------------
REST API - layer
In this test you are required to develop a small scale widget API by the following spec:
The system should get a web request with the following parameters - Widget name, widget parameters. For example the call should be in post to the URL localhost/method with the following payload:{widgetName=abc,params={fromDate:"1\2\2016",toDate:"2\2\2016",cust_id:"20"}}
The system should return the results of the query in JSON format
A widget object template contains SQL query and parameters (names and types) - a template will be saved in file in JSON/XML format (your call)
On load, the service should get a directory as parameter and loads all template files into dictionary
The query process should be as follow:
We should first resolve the widget name from the loaded widget dictionary
If the widget exists we should validate that all parameters are there and the types are correct
format the query with the given parameters
execute the query against mysql
return results as JSON
An example query on our data can be:
Widgit 1 (events per day for last x days):
ReceiveParams = { "clinet_id":int, "from_date":datetime, "to_date":datetime },
QueryText = "
SELECT clinet_id,count(*) AS events_count
FROM events
WHERE (event_ts >= {1} and event_ts < {2}
AND clinet_id = {0}
GROUP BY 1
ORDER BY 1,
"
Definitions:
events table
event_id int
event_ts datetime
event_type int (1 = impression, 2 = click, 3 = purchase...)
clinet_id into
you can use flask or django