Slide 1

Slide 1 text

https://www.flickr.com/photos/iangbl/

Slide 2

Slide 2 text

https://www.flickr.com/photos/florianric/

Slide 3

Slide 3 text

https://www.flickr.com/photos/pennuja/

Slide 4

Slide 4 text

Yeah, we could make that work.

Slide 5

Slide 5 text

Yeah, we could make that work. But…

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Content

Slide 13

Slide 13 text

Content Users

Slide 14

Slide 14 text

Content Users Voting

Slide 15

Slide 15 text

https://www.flickr.com/photos/beraldoleal

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

Route::get('/', array( 'as' => 'home', 'uses' => 'HomeController@ ', 'after' => 'cache' )); showVoteHome

Slide 18

Slide 18 text

! ! Route::filter('cache', function($route, $request, $response, $max_age=1200) { });

Slide 19

Slide 19 text

class Nominee extends Eloquent { ! // ... ! }

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

SELECT description, body, tagline, hashtag, closingTime FROM craft_content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

// ... } class Nominee extends Eloquent {

Slide 33

Slide 33 text

// ... } class Nominee extends Eloquent { protected $table = 'craft_entries_i18n';

Slide 34

Slide 34 text

// ... } class Nominee extends Eloquent { protected $table = 'craft_entries_i18n'; private $sectionId = 2;

Slide 35

Slide 35 text

public function scopeListing($query) { return $query ->select( /* ... */ ) ->join( /* ... */ ) ->where( /* ... */ ); }

Slide 36

Slide 36 text

public function scopeListing($query) { return $query ->select( /* ... */ ) ->join('craft_content', 'craft_content.elementId', '=', 'craft_entries_i18n.entryId') ->join('craft_entries', 'craft_entries.id', '=', 'craft_entries_i18n.entryId') ->join('craft_elements', 'craft_elements.id', '=', 'craft_entries_i18n.entryId') ->where('craft_entries_i18n.sectionId','=',$this->sectionId) ->where('craft_entries.postDate','<=',date_format(new DateTime(),'Y-m-d G:i:s')) ->where(function($query) { $query ->where('craft_entries.expiryDate','=',NULL) ->orWhere('craft_entries.expiryDate','>=',date_format(new DateTime(),'Y-m-d G:i:s')); }) ->where('craft_elements.enabled','=',1); }

Slide 37

Slide 37 text

->where( 'craft_entries_i18n.sectionId','=', $this->sectionId )

Slide 38

Slide 38 text

->join('craft_content', 'craft_content.elementId', '=', 'craft_entries_i18n.entryId' )

Slide 39

Slide 39 text

->join('craft_entries', 'craft_entries.id', '=', 'craft_entries_i18n.entryId' )

Slide 40

Slide 40 text

->where('craft_entries.postDate','<=', date_format(new DateTime(),'Y-m-d G:i:s') )

Slide 41

Slide 41 text

->where(function($query) { $query ->where('craft_entries.expiryDate','=',NULL) ->orWhere('craft_entries.expiryDate','>=', date_format(new DateTime(),'Y-m-d G:i:s')); })

Slide 42

Slide 42 text

->join('craft_elements', 'craft_elements.id', '=', 'craft_entries_i18n.entryId' )

Slide 43

Slide 43 text

->where('craft_elements.enabled','=',1)

Slide 44

Slide 44 text

public function scopeListing($query) { return $query ->select( /* ... */ ) ->join( /* ... */ ) ->where( /* ... */ ); }

Slide 45

Slide 45 text

$nominees = Nominee::listing() ->orderBy('craft_entries_i18n.title') ->get();

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Users

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

// ... } class User extends Eloquent {

Slide 56

Slide 56 text

// ... } class User extends Eloquent { protected $table = 'craft_users';

Slide 57

Slide 57 text

craft_users id username firstName lastName status

Slide 58

Slide 58 text

oma_users userId avatar bio providerData providerTokens craft_users id username firstName lastName status

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Voting

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

public function cast($voterId, $nomineeId, $categoryId, $influencerId = 0) { ! // ... ! }

Slide 66

Slide 66 text

$redis = Redis::connection('oma4-votes'); ! $voter = "user[{$voterId}]"; $nominee = "nominee[{$nomineeId}]"; $category = "category[{$categoryId}]"; $influencer = “user[{$influencerId}]”; ! $datetime = new DateTime(); $date['day'] = $datetime->format('Y-m-d'); $date['hour'] = $datetime->format('Y-m-d-H');

Slide 67

Slide 67 text

// Vote Counts $redis->incrby('votes',1); $redis->hincrby("votes:{$voter}",'total',1); $redis->hincrby("votes:{$voter}",'cast',1);

Slide 68

Slide 68 text

// Nominee Standings $redis->zincrby("standings:nominee",1,$nominee); $redis->zincrby("standings:nominee:{$category}",1,$nominee); $redis->zincrby("standings:nominee:{$voter}",1,$nominee);

Slide 69

Slide 69 text

$redis->zrevrange( "standings:nominee", 0, -1, 'WITHSCORES' );

Slide 70

Slide 70 text

// Activity Trends $redis->hincrby("trends:{$voter}",$date['day'],1); $redis->hincrby("trends:{$voter}",$date['hour'],1); $redis->hincrby("trends:{$nominee}",$date['hour'],1); $redis->hincrby("trends:{$category}",$date['hour'],1);

Slide 71

Slide 71 text

$hourOne = $redis->hget("trends:{$nominee}", '2013-06-19-20'); $hourTwo = $redis->hget("trends:{$nominee}", '2013-06-19-21'); $hourThree = $redis->hget("trends:{$nominee}", '2013-06-19-22');

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

Be Pragmatic.

Slide 79

Slide 79 text

@acolangelo