Changeset 1017
- Timestamp:
- 08/23/06 00:14:13 (2 years ago)
- Files:
-
- feedmelinks/admin/FUQ/index.php (modified) (6 diffs)
- feedmelinks/login.php (modified) (1 diff)
- feedmelinks/modules/tags (added)
- feedmelinks/modules/utils.inc.php (modified) (3 diffs)
- feedmelinks/testing/date-compare.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
feedmelinks/admin/FUQ/index.php
r1008 r1017 10 10 include( "$modules/header.inc.php" ); 11 11 $bg = " bgcolor='#888888' "; 12 13 12 14 %> 13 15 <h1><%= $title %></h1> … … 18 20 border: 1px solid gray; 19 21 } 20 thead { 22 thead, tfoot { 23 color: red; 21 24 font-weight: bold; 22 25 } … … 30 33 </style> 31 34 32 <a href="http://toolstomaketools.svnrepository.com/codepot/trac.cgi/ticket/42">the FUQ roadmap</a>35 Threshold: <%= get_fuq_threshold() %> 33 36 34 37 <table> … … 36 39 <tr> 37 40 <td> 38 USER 41 42 </td> 43 <td> 44 ∂ t betw links (hrs); HIGHER = more humane 45 </td> 46 <td> 47 recency (days) 48 </td> 49 <td> 50 length of usage (days); HIGHER = more humane 39 51 </td> 40 52 <td> 41 53 FUQ 42 </td>43 <td>44 recalc'd FUQ45 </td>46 <td>47 δ two48 54 </td> 49 55 </tr> … … 51 57 <tbody> 52 58 <% 53 $gp = $guinea_pigs = array( "BrittanySCarter", "pheezy", "gus", "TheFaction", "Cashak", "ahhsum4", "ina", "jm3", "scordero", "testuser1", "knormile", "heathleah", "Kruther1934"); 59 $gp = $guinea_pigs = 60 array( 61 "pheezy", 62 "gus", 63 "Cashak", 64 "ahhsum4", 65 "ina", 66 "jm3", 67 "formalplay", 68 "DRaupp", 69 "BrittanySCarter", 70 "scordero", 71 "testuser1", 72 "knormile", 73 "heathleah", 74 "TheFaction", 75 "Kruther1934" 76 ); 54 77 $flip = 0; 55 78 foreach( $gp as $g ) { 79 80 $fuq = get_fuq( $g ); 81 if( $recalc ) 82 $fuq = recalculate_fuq( $g ); 83 84 if( $fuq < get_fuq_threshold() ) 85 $fuqqed = true; 56 86 %> 57 <tr <%= ($flip % 2) == 0 ? "class='tr1'" : ""%>>87 <tr <%= $fuqqed ? "class='FUQQED'" : (($flip % 2) == 0 ? "class='tr1'" : "") %>> 58 88 <td> 59 89 <a href="/u/<%= $g %>"><%= $g %></a> 60 90 </td> 61 91 <td> 62 <%= get_fuq( $g ) %> 92 <%= delta_time_between_links( $g, $raw = true ) %>, 93 <%= delta_time_between_links( $g ) %> 63 94 </td> 64 95 <td> 65 <%= rec alculate_fuq( $g) %>96 <%= recency( $g, $raw = true ) %> 66 97 </td> 67 98 <td> 68 δ last two links: <%= get_fuqqed( $g, 0 ) %> 99 <%= length_of_usage( $g, $raw = true ) %> 100 </td> 101 <td> 102 <%= 1/recency( $g, $raw = true ) * length_of_usage( $g, $raw = true ) / 1000 %> 103 </td> 104 <td> 105 <%= $fuq %> 69 106 </td> 70 107 </tr> … … 73 110 } 74 111 %> 112 <tfoot> 113 <tr> 114 <td> 115 116 </td> 117 <td> 118 < 0.5 = MINUS 1<br /> 119 > 10 = PLUS 1<br /> 120 </td> 121 <td> 122 </td> 123 <td> 124 > 45 = PLUS 1 125 </td> 126 </tr> 127 </tfoot> 75 128 <tbody> 76 129 </table> 130 131 <p /> 132 133 <form> 134 <input type="hidden" name="recalc" value="1" /> 135 <input type="submit" value="recalculate FUQs for these users " /> 136 </form> 137 138 139 <p> 140 <a href="http://toolstomaketools.svnrepository.com/codepot/trac.cgi/ticket/42">the FUQ roadmap</a> 141 </p> 77 142 78 143 <% include( "$modules/footer.inc.php" ); %> feedmelinks/login.php
r960 r1017 133 133 134 134 Save this message under your pillow in case you forget your username 135 and password. Email " . get_maintainer_email() . " with any questions or comments.135 and password. Email " . get_maintainer_email() . " with any questions or comments. 136 136 137 137 Happy Linking! 138 138 139 139 - jm3 140 john manoogian III 140 141 Feed Me Links 141 142 "; feedmelinks/modules/utils.inc.php
r1015 r1017 8 8 return run_count( getQuery( "link_exists_for_user", $url, $u )); 9 9 } 10 11 function diff_in_secs( $db_date_0, $db_date_1 ) { 12 $dt0 = strtotime( $db_date_0 ); 13 $dt1 = strtotime( $db_date_1 ); 14 return( $dt0 - $dt1 ); 15 } 16 17 function get_db_date_diff_in_days( $qs ) { 18 $con_fuq_slot = mysql_connect(); 19 mysql_selectdb( getDBName() ); 20 $q = mysql_query( $qs ); 21 if( ! $q ) 22 return undefined; 23 24 $d0 = mysql_result($q,0); 25 $d1 = mysql_result($q,1); 26 $diff = round( diff_in_secs( $d0, $d1 ) / 60 / 60 / 24, 4); 27 return $diff > 0 ? $diff : 0; 28 } 29 30 function get_simple_rs( $qs ) { 31 $con = mysql_connect(); 32 mysql_selectdb( getDBName() ); 33 $q = mysql_query( $qs ); 34 if( ! $q ) 35 return undefined; 36 37 return mysql_result($q,0); 38 } 39 40 function get_fuq_threshold() { return 2; } 10 41 11 42 function get_fuq( $u ) { … … 23 54 } 24 55 56 function delta_time_between_links( $u, $raw = false ) { 57 $value = get_db_date_diff_in_days( getQuery( "get_fuq_slot_delta_time_between_links", $u )) * 60; 58 if( $raw ) 59 return $value; 60 else 61 if( $value < 0.5 ) 62 return -1; 63 else if( $value > 10 ) 64 return 1; 65 else 66 return 0; 67 } 68 69 function recency( $u, $raw = false ) { 70 $d0 = get_simple_rs( getQuery( "get_fuq_slot_recency", $u )); 71 72 $now = getdate(); 73 $d1 = $now['year'] ."-". ($now['mon'] < 10 ? "0" : "" ) . $now['mon'] ."-". ($now['mday'] < 10 ? "0" : "" ) . $now['mday'] ." ". $now['hours'] .":". $now['minutes'] .":". $now['seconds']; 74 $value = round( diff_in_secs( $d1, $d0 ) / 60 / 60 / 24, 3 ); 75 return $value; 76 } 77 78 function length_of_usage( $u, $raw = false ) { 79 $r0 = get_simple_rs( "SELECT createDate FROM links WHERE submitter = '" . urlencode( $u ) . "' ORDER BY id DESC LIMIT 1;" ); 80 $r1 = get_simple_rs( "SELECT createDate FROM links WHERE submitter = '" . urlencode( $u ) . "' ORDER BY id ASC LIMIT 1;" ); 81 $value = round( diff_in_secs( $r0, $r1 ) / 60 / 60 / 24, 1 ); 82 return $value; 83 } 84 85 #loops through the fuq metrics, calculating each of them, and mashes them together to re-calculate a users FUQ 25 86 function recalculate_fuq( $u ) { 26 run_query( getQuery( "update_fuq", $u, $retval = get_fuq( $u )+0)); 27 return $retval; 87 88 # calculate new fuq: 89 $new_fuq = get_fuq( $u ); 90 91 $slots = array( 92 "delta_time_between_links" => 0, 93 "length_of_usage" => 0 94 ); 95 96 foreach( $slots as $key => $value ) { $slots[$key] = call_user_func( $key, $u ); } 97 98 # mash together slot values here: 99 # TBD 100 101 #foreach( $slots as $slot ) { echo "\$slot = $slot<br>"; } 102 103 return; 104 105 run_query( getQuery( "update_fuq", $u, $new_fuq )); # and then set it 106 return $new_fuq; 28 107 } 29 108 … … 1248 1327 } else if( $argWhichQuery == "get_fuq" ) { 1249 1328 return "SELECT FUQ from linksUsers WHERE userid = '" . urlencode( $args[1] ) . "';"; 1250 1329 1330 } else if( $argWhichQuery == "get_fuq_slot_delta_time_between_links" ) { 1331 return "SELECT createDate FROM links WHERE submitter = '" . urlencode( $args[1] ) ."' ORDER BY id DESC LIMIT 2;"; 1332 1333 } else if( $argWhichQuery == "get_fuq_slot_recency" ) { 1334 return "select createDate from links where submitter = '" . urlencode( $args[1] ) ."' ORDER BY id DESC LIMIT 1;"; 1335 1251 1336 } else if( $argWhichQuery == "link_exists_for_user" ) { 1252 1337 return "SELECT COUNT(url) FROM links WHERE url = '" . urlencode( $args[1] ) . "' AND submitter = '" . urlencode( $args[2] ) . "';";