Changeset 1114 for trunk/common


Ignore:
Timestamp:
03/20/10 16:19:40 (2 years ago)
Author:
wefgef
Message:

Added new rating count column in round tasks table.

  • Added a new security action.
  • Added a new select statement to get the tasks rating count.
  • Added a new column in the Tasks macro.

REVIEW URL http://reviewboard.infoarena.ro/r/141/

Location:
trunk/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/db/round.php

    r1110 r1114  
    104104// 
    105105// if user_id is non-null a join is done on $score 
    106 function round_get_tasks($round_id, $first = 0, $count = null, $user_id = null, $fetch_scores = false, $filter = null) { 
     106function round_get_tasks($round_id, $first = 0, $count = null, 
     107                         $user_id = null, $fetch_scores = false, 
     108                         $filter = null, $progress = false) { 
    107109    if ($count === null) { 
    108110        $count = 666013; 
     
    141143                         db_escape($first), db_escape($count)); 
    142144    } 
    143     return db_fetch_all($query); 
     145 
     146    $res = db_fetch_all($query); 
     147 
     148    if ($progress) { 
     149        $task_ids = array(); 
     150        foreach ($res as $row) { 
     151            $task_ids[] = $row['id']; 
     152        } 
     153 
     154        $query_ratings = sprintf( 
     155              "SELECT task_ratings.task_id AS id, count(*) AS rating_count 
     156               FROM ia_task_ratings AS task_ratings 
     157               WHERE task_ratings.task_id IN (%s) 
     158               GROUP BY id", 
     159               implode(',', array_map('db_quote', $task_ids)) 
     160        ); 
     161 
     162        $res_ratings = db_fetch_all($query_ratings); 
     163 
     164        $rating_count = array(); 
     165        foreach ($res_ratings as $res_rating) { 
     166            $rating_count[$res_rating['id']] = $res_rating['rating_count']; 
     167        } 
     168 
     169        foreach ($res as &$row) { 
     170            $row['progress'] = getattr($rating_count, $row['id']); 
     171        } 
     172    } 
     173 
     174    return $res; 
    144175} 
    145176 
  • trunk/common/security.php

    r1111 r1114  
    147147        case 'task-edit-ratings': 
    148148        case 'round-tag': 
     149        case 'round-view-progress': 
    149150        case 'textblock-tag': 
    150151        case 'job-reeval': 
Note: See TracChangeset for help on using the changeset viewer.