Skip to content

Commit

Permalink
Fixed Billing Dashboard Bugs, Modified Logic and Added Invoice Number…
Browse files Browse the repository at this point in the history
…ing 2.0
  • Loading branch information
Harin329 committed Jul 16, 2023
1 parent 8549c66 commit 8fcb63b
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 16 deletions.
13 changes: 13 additions & 0 deletions backend/src/controllers/clicksController.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,17 @@ export default class ClicksController {
});
});
}

getClicks(req) {
return new Promise((resolve, reject) => {
const ClicksModel = new Clicks();

ClicksModel.getClicks(req, (err, result) => {
if (err) {
reject({ error: err });
}
resolve(result);
});
});
}
}
17 changes: 17 additions & 0 deletions backend/src/models/clicks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,21 @@ export class Clicks {
}
);
}

getClicks(component_name, result) {
con.query(
"CALL get_count(?)",
[
component_name
],
function (error, results) {
if (error) {
console.log("error: ", error);
result(error, null);
} else {
result(null, results[0]);
}
}
);
}
}
47 changes: 32 additions & 15 deletions backend/src/routes/clicksRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,38 @@ const router = Router();
const clicksController = new ClicksController();

router.post("/", authorize(), (req, res) => {
if(!req.body) {
res.status(400).send({
message: "Content can not be empty!"
});
return;
}

clicksController
.saveClicks(req)
.then((response) => {
res.status(200).json(response);
})
.catch((err) => {
res.status(404).json(err);
});
if (!req.body) {
res.status(400).send({
message: "Content can not be empty!"
});
return;
}

clicksController
.saveClicks(req)
.then((response) => {
res.status(200).json(response);
})
.catch((err) => {
res.status(404).json(err);
});
});

router.get("/:componentName", authorize(), (req, res) => {
if (!req.params.componentName) {
res.status(400).send({
message: "Content can not be empty!"
});
}

clicksController
.getClicks(req.params.componentName)
.then((response) => {
res.status(200).json(response);
})
.catch((err) => {
res.status(404).json(err);
});
});

export default router;
2 changes: 1 addition & 1 deletion database/procedures/billableProc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ BEGIN
AND (created_by = _user_id OR _user_id IS NULL OR _user_id = '')
AND ((createdDate BETWEEN _start_date AND _end_date) OR (_start_date IS NULL OR _end_date IS NULL))
AND (((t.task_state != "archived" OR t.task_state IS NULL) and (st.subtask_state != "archived" OR st.subtask_state IS NULL) and (_archive IS NULL OR _archive = 0)) OR _archive = 1)
AND (_billed OR ((_billed IS NULL OR _billed = 0) AND billable.billed = 0))
AND ((_billed AND billable.billed = 1) OR ((_billed IS NULL OR _billed = 0) AND billable.billed = 0))
AND (((t.task_state = "completed" OR st.subtask_state = "completed") AND _ready_to_bill = 1) OR _ready_to_bill = 0 OR _ready_to_bill IS NULL);

END $$
Expand Down
8 changes: 8 additions & 0 deletions database/procedures/clickAnalytics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ USE `labby`;

DROP PROCEDURE IF EXISTS `update_count`;
DROP PROCEDURE IF EXISTS `initialize_count`;
DROP PROCEDURE IF EXISTS `get_count`;

DELIMITER $$

Expand All @@ -12,6 +13,13 @@ BEGIN
WHERE component = component_name;
END$$

CREATE PROCEDURE `get_count`(IN component_name VARCHAR(50))
BEGIN
SELECT click_count
FROM click_analytics
WHERE component = component_name;
END$$


CREATE PROCEDURE `initialize_count`(IN component_name VARCHAR(50))
BEGIN
Expand Down

0 comments on commit 8fcb63b

Please sign in to comment.