Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nCodeProject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adarsh Shetty
nCodeProject
Commits
75b46974
Commit
75b46974
authored
5 months ago
by
Vinod Bangera
Browse files
Options
Downloads
Patches
Plain Diff
added gitignore and table creation
parent
876ea386
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.env
+0
-6
0 additions, 6 deletions
.env
.gitignore
+28
-0
28 additions, 0 deletions
.gitignore
config/db.js
+22
-2
22 additions, 2 deletions
config/db.js
with
50 additions
and
8 deletions
.env
deleted
100644 → 0
+
0
−
6
View file @
876ea386
PORT=5000
DB_USER=postgres
DB_HOST=127.0.0.1
DB_NAME=my_pgdb
DB_PASSWORD=Adarsh@2002
DB_PORT=5432
\ No newline at end of file
This diff is collapsed.
Click to expand it.
.gitignore
0 → 100644
+
28
−
0
View file @
75b46974
# Node.js
node_modules/
npm-debug.log
yarn-error.log
# Environment variables
.env
# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Database
*.sqlite
*.sqlite3
# IDEs and editors
.vscode/
.idea/
*.sublime-project
*.sublime-workspace
# Operating system files
.DS_Store
Thumbs.db
\ No newline at end of file
This diff is collapsed.
Click to expand it.
config/db.js
+
22
−
2
View file @
75b46974
...
@@ -10,7 +10,27 @@ const pool = new Pool({
...
@@ -10,7 +10,27 @@ const pool = new Pool({
});
});
pool
.
connect
()
pool
.
connect
()
.
then
(()
=>
console
.
log
(
"
PostgreSQL Database Connected Successfully
"
))
.
then
(
async
(
client
)
=>
{
console
.
log
(
"
PostgreSQL Database Connected Successfully
"
);
const
createTableQuery
=
`
CREATE TABLE IF NOT EXISTS usage_metrics (
id SERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL,
projectId VARCHAR(255) NOT NULL,
requestType VARCHAR(50) CHECK (requestType IN ('completion', 'explanation', 'documentation', 'testcase')),
linesOfCodeSuggested INT DEFAULT 0,
linesOfCodeAccepted INT DEFAULT 0,
requestId UUID DEFAULT gen_random_uuid(),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
`
;
await
client
.
query
(
createTableQuery
);
console
.
log
(
"
Table 'usage_metrics' is ready
"
);
client
.
release
();
})
.
catch
((
err
)
=>
console
.
error
(
"
Database Connection Failed:
"
,
err
));
.
catch
((
err
)
=>
console
.
error
(
"
Database Connection Failed:
"
,
err
));
module
.
exports
=
pool
;
module
.
exports
=
pool
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment