Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corps-directory
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fhurtado14
corps-directory
Merge requests
!8
Feature/activity logger
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feature/activity logger
feature/activity-logger
into
main
Overview
0
Commits
9
Pipelines
0
Changes
4
Merged
fhurtado14
requested to merge
feature/activity-logger
into
main
5 months ago
Overview
0
Commits
9
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Viewing commit
4e720744
Prev
Next
Show latest version
4 files
+
53
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
4e720744
Create repository for database change logs, but we need to wait to setup JWT to implement this.
· 4e720744
Federico Hurtado
authored
5 months ago
backend/repository/activityRepository.js
+
36
−
1
Options
@@ -47,7 +47,41 @@ async function getLoginDataTimerange(start, end) {
async
function
getLoginDataByUser
()
{}
async
function
logDatabaseChange
()
{}
/*
Insert a row into changeLog which keeps track of every time the database is changed.
*/
async
function
logDatabaseChange
(
tableName
,
recordId
,
userId
,
changeType
,
changedColumns
,
oldValues
,
newValues
)
{
const
query
=
`
INSERT INTO changeLog (changedTable, recordId, userId, changeType, changedColumns, oldValues, newValues)
VALUES (?, ?, ?, ?, ?, ?, ?)
`
;
const
values
=
[
tableName
,
recordId
,
userId
,
changeType
,
changedColumns
,
oldValues
,
newValues
,
];
try
{
await
pool
.
query
(
query
,
values
);
console
.
log
(
"
Change logged successfully.
"
);
}
catch
(
error
)
{
// throw error to be caught by service
console
.
log
(
"
activity repository error when logging change:
"
,
error
);
throw
error
;
}
}
async
function
getDatabaseChangeTimerange
()
{}
@@ -56,4 +90,5 @@ async function getDatabaseChangeByUser() {}
module
.
exports
=
{
logSuccessfulLogin
,
getLoginDataTimerange
,
logDatabaseChange
,
};
Loading