feat : List of who are not login in mentioned time duration
This commit is contained in:
@@ -93,9 +93,9 @@ async function getTransactions(req, res) {
|
||||
from_account: u.from_account,
|
||||
to_account: u.to_account,
|
||||
ifsc_code: u.ifsc_code,
|
||||
amount :u.amount,
|
||||
created_at :u.created_at,
|
||||
trx_type:u.trx_type,
|
||||
amount: u.amount,
|
||||
created_at: u.created_at,
|
||||
trx_type: u.trx_type,
|
||||
status: u.status,
|
||||
}));
|
||||
|
||||
@@ -132,9 +132,9 @@ async function getFailedTransactions(req, res) {
|
||||
from_account: u.from_account,
|
||||
to_account: u.to_account,
|
||||
ifsc_code: u.ifsc_code,
|
||||
amount :u.amount,
|
||||
created_at :u.created_at,
|
||||
trx_type:u.trx_type,
|
||||
amount: u.amount,
|
||||
created_at: u.created_at,
|
||||
trx_type: u.trx_type,
|
||||
status: u.status,
|
||||
}));
|
||||
|
||||
@@ -146,4 +146,33 @@ async function getFailedTransactions(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { active_users ,inactive_users, getTransactions ,getFailedTransactions };
|
||||
async function getDetailsOfNotLoginWithinDuration(req, res) {
|
||||
const {
|
||||
duration
|
||||
} = req.body;
|
||||
|
||||
if (!duration) {
|
||||
return res.status(400).json({ error: 'Duration are required' });
|
||||
}
|
||||
|
||||
try {
|
||||
const users = await reportService.getNotLogin(duration);
|
||||
const user_list = users.map(u => ({
|
||||
|
||||
customer_no: u.customer_no,
|
||||
user_name: u.preferred_name,
|
||||
last_login: u.last_login,
|
||||
created_at: u.created_at,
|
||||
locked: u.locked,
|
||||
status: u.status,
|
||||
}));
|
||||
|
||||
res.json({ count: users.length, user_list });
|
||||
|
||||
} catch (err) {
|
||||
logger.error(err, 'failed to fetch not logged in user details');
|
||||
res.status(500).json({ error: 'something went wrong' });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { active_users, inactive_users, getTransactions, getFailedTransactions, getDetailsOfNotLoginWithinDuration };
|
||||
@@ -7,5 +7,6 @@ router.post('/active_users', reportController.active_users);
|
||||
router.post('/in-active_users', reportController.inactive_users);
|
||||
router.post('/transaction_report', reportController.getTransactions);
|
||||
router.post('/failed_transaction_report', reportController.getFailedTransactions);
|
||||
router.post('/not_logged_in', reportController.getDetailsOfNotLoginWithinDuration);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -89,5 +89,18 @@ async function getFailedTransactions(filters) {
|
||||
}
|
||||
}
|
||||
|
||||
async function getNotLogin(duration) {
|
||||
try {
|
||||
const result = await db.query(
|
||||
`SELECT * FROM users WHERE last_login <= NOW() - ($1 || ' month')::interval`,
|
||||
[duration]
|
||||
);
|
||||
logger.info("data fetch for users who have not logged-in in mentioned duration");
|
||||
return result.rows;
|
||||
} catch (err) {
|
||||
logger.error(err, 'failed to fetch not logged-in users data');
|
||||
res.status(500).json({ error: 'something went wrong' });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { total_users ,getTransactions ,getFailedTransactions };
|
||||
module.exports = { total_users, getTransactions, getFailedTransactions, getNotLogin };
|
||||
Reference in New Issue
Block a user