Fixed stats readout
This commit is contained in:
parent
060ce6964c
commit
df86ba7160
3 changed files with 6 additions and 4 deletions
|
@ -34,7 +34,7 @@ class DbOperations
|
||||||
$this->pdo = new PDO($dsn, $this->config['username'], $this->config['password'], $options);
|
$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;
|
$this->table = $this->tablePrefix . $table;
|
||||||
if (count($attributes) == 0)
|
if (count($attributes) == 0)
|
||||||
|
@ -42,7 +42,8 @@ class DbOperations
|
||||||
else {
|
else {
|
||||||
for ($i = 0; $i < count($attributes); $i++) {
|
for ($i = 0; $i < count($attributes); $i++) {
|
||||||
$a = $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";
|
$attributes[$i] = "$this->table.$a";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ function getProjectRecordDerivedData($user_id, $project_id)
|
||||||
$recordCountAttribute = "COUNT(*) AS record_count";
|
$recordCountAttribute = "COUNT(*) AS record_count";
|
||||||
|
|
||||||
$db = new DbOperations();
|
$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("user_id", Comparison::EQUAL, $user_id);
|
||||||
$db->where("project_id", Comparison::EQUAL, $project_id);
|
$db->where("project_id", Comparison::EQUAL, $project_id);
|
||||||
$results = $db->execute();
|
$results = $db->execute();
|
||||||
|
|
|
@ -5,6 +5,7 @@ const PROJECT_META = "p";
|
||||||
function loadProjectList() {
|
function loadProjectList() {
|
||||||
api.getProjects().then((projects) => {
|
api.getProjects().then((projects) => {
|
||||||
var container = u(u("#project-list").first());
|
var container = u(u("#project-list").first());
|
||||||
|
container.children().remove();
|
||||||
Object.values(projects).forEach((project) => {
|
Object.values(projects).forEach((project) => {
|
||||||
var obj = createNode(PROJECT_OBJECT);
|
var obj = createNode(PROJECT_OBJECT);
|
||||||
var data = undefined;
|
var data = undefined;
|
||||||
|
@ -13,7 +14,7 @@ function loadProjectList() {
|
||||||
append(obj, data);
|
append(obj, data);
|
||||||
u(data).text(project["name"]);
|
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";
|
var unit = "hours";
|
||||||
data = createNode(PROJECT_META);
|
data = createNode(PROJECT_META);
|
||||||
append(obj, data);
|
append(obj, data);
|
||||||
|
|
Loading…
Reference in a new issue