How is registered tags quota calculated?
From PTAGISWiki
The registered tag quota for a user is displayed at the bottom of the My Registered Tags page. The jsp calculates the quota and the usage with this code:
nQuota= ((Long) session.getAttribute("reg_tags_quota")).longValue();
nUsage= (int) Math.floor(oRegTags.getTotalTagStorageSizeInBytes(userName)*100/nQuota);
The oRegTags object has this code:
/**
* Retrieves the sum of the tag counts in the user's tag groups.
* This method has been updated to return the actual number of tags,
* rather than their size in bytes!
* @param userName the name of the user
* @return the sum of the tag counts in the user's tag groups
*/
public int getTotalTagStorageSizeInBytes(String userName) throws SQLException
{
Connection oConn= null;
int nTagCount= 0;
try {
oConn= m_oDBConnection.newConnectionB(Connection.TRANSACTION_READ_UNCOMMITTED);
oConn.setAutoCommit(false);
String sCmd= "SELECT SUM(num_tags_contained) FROM mrt_tag_groups WHERE user_name=?";
PreparedStatement oStmt= oConn.prepareStatement(sCmd,ResultSet.TYPE_FORWARD_ONLY,ResultSet.
CONCUR_READ_ONLY);
oStmt.setString(1,userName);
ResultSet oRS= oStmt.executeQuery();
nTagCount= oRS.next()? oRS.getInt(1): 0;
oRS.close();
oStmt.close();
oConn.commit();
}catch(SQLException e){
oConn.rollback();
throw(e);
}finally{
if (oConn!=null){ oConn.rollback(); oConn.close(); }
}
return nTagCount;
}
