Fixed stats readout

This commit is contained in:
Maximilian Giller 2020-11-21 00:49:22 +01:00
parent 060ce6964c
commit df86ba7160
3 changed files with 6 additions and 4 deletions

View file

@ -34,7 +34,7 @@ class DbOperations
$this->pdo = new PDO($dsn, $this->config['username'], $this->config['password'], $options);
}
function select(string $table, array $attributes = array())
function select(string $table, array $attributes = array(), bool $addTableName = true)
{
$this->table = $this->tablePrefix . $table;
if (count($attributes) == 0)
@ -42,7 +42,8 @@ class DbOperations
else {
for ($i = 0; $i < count($attributes); $i++) {
$a = $attributes[$i];
if (strpos($a, ".") === false) {
// Add table name prefix if missing
if ($addTableName && strpos($a, ".") === false) {
$attributes[$i] = "$this->table.$a";
}
}

View file

@ -76,7 +76,7 @@ function getProjectRecordDerivedData($user_id, $project_id)
$recordCountAttribute = "COUNT(*) AS record_count";
$db = new DbOperations();
$db->select("time_records", ["*", $durationAttribute, $recordCountAttribute]);
$db->select("time_records", ["*", $durationAttribute, $recordCountAttribute], false);
$db->where("user_id", Comparison::EQUAL, $user_id);
$db->where("project_id", Comparison::EQUAL, $project_id);
$results = $db->execute();

View file

@ -5,6 +5,7 @@ const PROJECT_META = "p";
function loadProjectList() {
api.getProjects().then((projects) => {
var container = u(u("#project-list").first());
container.children().remove();
Object.values(projects).forEach((project) => {
var obj = createNode(PROJECT_OBJECT);
var data = undefined;
@ -13,7 +14,7 @@ function loadProjectList() {
append(obj, data);
u(data).text(project["name"]);
var duration = parseFloat(project["duration"]) / 60 / 60;
var duration = Number((parseFloat(project["duration"]) / 60 / 60).toFixed(2));
var unit = "hours";
data = createNode(PROJECT_META);
append(obj, data);