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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
<?php namespace controller;
class Coverflows {
public function getSuggestedPeople_cache() { $db = \MysqliDb::getInstance(); $cols = Array ("id", "name", "img"); $res = $db->get('actors', null, $cols);
$ret = array(); for($i = 20; $i < 40; $i++) { $ret[] = array( "user_id"=>$res[$i]['id'], "image"=>"https://image.tmdb.org/t/p/w300/" . $res[$i]['img'], "user_name"=>$res[$i]['name'], "total_followers"=>rand(0, 1000), "total_following"=>rand(0, 1000), "things_in_common"=>rand(0, 150) ); } return json_encode($ret, JSON_UNESCAPED_SLASHES); }
public function getSuggestedPeople_elastic() { $body = file_get_contents('php://input'); $requstOb = json_decode($body,true); //$db = \MysqliDb::getInstance(); $quotes = array( "Movie lover 1", "Movie lover 2", "Movie lover 3", "Another movie lover 1", "Another movie lover 2", "Another movie lover 3", ); $ret = array(); for($i = 0; $i < count($requstOb['user_ids']); $i++) { $ret[] = array( "user_id"=>$requstOb['user_ids'][$i], "quote"=>$quotes[rand(0,5)] ); } return json_encode($ret, JSON_UNESCAPED_SLASHES); }
public function getMoviesFromMyNetwork_cache() { $db = \MysqliDb::getInstance(); $cols = Array ("id"); $res = $db->get('movies', null, $cols); for($i = 20; $i < 25; $i++) { $ret[] = $res[$i]['id']; } return json_encode($ret); } public function getMoviesFromMyNetwork_elastic() { $body = file_get_contents('php://input'); $requstOb = json_decode($body,true);
$db = \MysqliDb::getInstance(); $sql = 'select id,title,default_cover_url from movies where id in (' . implode($requstOb['movie_ids'], ",").')';
$movies = $db->rawQuery ('select id,title,default_cover_url from movies where id in (' . implode($requstOb['movie_ids'], ",").')'); $ret = array();
$followersIds = array("1,2,3,4,5,6,7,8,9,10,11"); for($i = 0; $i < count($movies); $i++) { $ret[] = array( "asset_id"=>$movies[$i]['id'], "title"=>$movies[$i]['title'], "cover"=>$movies[$i]['default_cover_url'], "short_description"=>"movie short description", "followers"=> array( "ids"=> $followersIds, "total_followers"=> rand(100, 1000), "others"=> rand(1000, 1500) ) ); } return json_encode($ret, JSON_UNESCAPED_SLASHES); } /* [{ "asset_id": number, // based on watched|collection|cowatch|rented of followings "type": number, // Values will be defined as const "watched_by": [{ "ids": [12 ids], "total": number // total for all or for following ??????????????? }] }]*/ public function getMostNoteworthyToday_cache() { $db = \MysqliDb::getInstance(); $cols = Array ("id"); $res = $db->get('movies', null, $cols);
$followersIds = array("1,2,3,4,5,6,7,8,9,10,11");
$ret = array(); for($i = 40; $i < 65; $i++) { $ret[] = array( "asset_id"=>$res[$i]['id'], "type"=>1, "watched_by" => array( "ids"=> $followersIds, "total"=>rand(100, 500) ) ); } return json_encode($ret); }
public function getMostNoteworthyToday_elastic() { $body = file_get_contents('php://input'); $requstOb = json_decode($body,true);
$db = \MysqliDb::getInstance(); $sql = 'select id,title,default_cover_url from movies where id in (' . implode($requstOb['movie_ids'], ",").')';
$movies = $db->rawQuery ('select id,title,default_cover_url from movies where id in (' . implode($requstOb['movie_ids'], ",").')'); $ret = array(); for($i = 0; $i < count($movies); $i++) { $ret[] = array( "asset_id"=>$movies[$i]['id'], "title"=>$movies[$i]['title'], "cover"=>$movies[$i]['default_cover_url'], "short_description"=>"movie short description", ); } return json_encode($ret, JSON_UNESCAPED_SLASHES); } } ?>
|