Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My #137

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open

My #137

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f9e79e8
Adding temporary changes to Github
Abhipadwal Oct 27, 2024
d67d288
Adding Login and register funconality
Abhipadwal Oct 28, 2024
9d1f564
changes made from theia lab environment"
Abhipadwal Oct 29, 2024
642b4b1
Add frontend for dealership
Abhipadwal Oct 29, 2024
7fac307
Create main.yml
Abhipadwal Oct 30, 2024
5fac419
Update models.py
Abhipadwal Oct 30, 2024
a889923
Update populate.py
Abhipadwal Oct 30, 2024
6a78966
Update restapis.py
Abhipadwal Oct 30, 2024
764c0c1
Update urls.py
Abhipadwal Oct 30, 2024
ac02567
Update views.py
Abhipadwal Oct 30, 2024
1e04cd1
Update settings.py
Abhipadwal Oct 30, 2024
cac7921
Update settings.py
Abhipadwal Oct 30, 2024
e93519e
Update urls.py
Abhipadwal Oct 30, 2024
ab1ee19
Update dealership.js
Abhipadwal Oct 30, 2024
21fcdd5
Update review.js
Abhipadwal Oct 30, 2024
1d8400d
Update inventory.js
Abhipadwal Oct 30, 2024
1ab4cb0
Update app.js
Abhipadwal Oct 30, 2024
ac13774
Update models.py
Abhipadwal Oct 30, 2024
bdc2ba4
Update populate.py
Abhipadwal Oct 30, 2024
bccd4a5
Update urls.py
Abhipadwal Oct 30, 2024
69f4c20
Update views.py
Abhipadwal Oct 30, 2024
4141020
Update settings.py
Abhipadwal Oct 30, 2024
5a0eb12
Update models.py
Abhipadwal Oct 30, 2024
26b45cf
Update models.py
Abhipadwal Oct 30, 2024
69f766c
Update models.py
Abhipadwal Oct 30, 2024
d39c707
Update models.py
Abhipadwal Oct 30, 2024
99757b1
Update models.py
Abhipadwal Oct 30, 2024
17cb613
Update models.py
Abhipadwal Oct 30, 2024
698ffdd
Update models.py
Abhipadwal Oct 30, 2024
e8c0949
Update models.py
Abhipadwal Oct 30, 2024
50a718a
Update populate.py
Abhipadwal Oct 30, 2024
8a4f398
Update populate.py
Abhipadwal Oct 30, 2024
3528adb
Update populate.py
Abhipadwal Oct 30, 2024
e72a6da
Update urls.py
Abhipadwal Oct 30, 2024
5514ce6
Update views.py
Abhipadwal Oct 30, 2024
0f171f5
Update settings.py
Abhipadwal Oct 30, 2024
002740f
Update views.py
Abhipadwal Oct 30, 2024
99912f9
Update views.py
Abhipadwal Oct 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Lint Code'
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
jobs:
lint_python:
name: Lint Python Files
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Print working directory
run: pwd
- name: Run Linter
run: |
pwd
# This command finds all Python files recursively and runs flake8 on them
find . -name "*.py" -exec flake8 {} +
echo "Linted all the python files successfully"
lint_js:
name: Lint JavaScript Files
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install JSHint
run: npm install jshint --global
- name: Run Linter
run: |
# This command finds all JavaScript files recursively and runs JSHint on them
find ./server/database -name "*.js" -exec jshint {} +
echo "Linted all the js files successfully"
94 changes: 55 additions & 39 deletions server/database/app.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
/*jshint esversion: 8 */
const express = require('express');
const mongoose = require('mongoose');
const fs = require('fs');
const cors = require('cors')
const app = express()
const cors = require('cors');

const app = express();
const port = 3030;

app.use(cors())
app.use(cors());
app.use(require('body-parser').urlencoded({ extended: false }));

const reviews_data = JSON.parse(fs.readFileSync("reviews.json", 'utf8'));
const dealerships_data = JSON.parse(fs.readFileSync("dealerships.json", 'utf8'));

mongoose.connect("mongodb://mongo_db:27017/",{'dbName':'dealershipsDB'});

mongoose.connect("mongodb://mongo_db:27017/", { dbName: 'dealershipsDB' });

const Reviews = require('./review');

const Dealerships = require('./dealership');

try {
Reviews.deleteMany({}).then(()=>{
Reviews.insertMany(reviews_data['reviews']);
});
Dealerships.deleteMany({}).then(()=>{
Dealerships.insertMany(dealerships_data['dealerships']);
});

} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
async function initializeDatabase() {
try {
await Reviews.deleteMany({});
await Reviews.insertMany(reviews_data.reviews);
await Dealerships.deleteMany({});
await Dealerships.insertMany(dealerships_data.dealerships);
} catch (error) {
console.error('Error fetching documents:', error);
}
}

initializeDatabase();

// Express route to home
app.get('/', async (req, res) => {
res.send("Welcome to the Mongoose API")
res.send("Welcome to the Mongoose API");
});

// Express route to fetch all reviews
Expand All @@ -49,7 +50,7 @@ app.get('/fetchReviews', async (req, res) => {
// Express route to fetch reviews by a particular dealer
app.get('/fetchReviews/dealer/:id', async (req, res) => {
try {
const documents = await Reviews.find({dealership: req.params.id});
const documents = await Reviews.find({ dealership: req.params.id });
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
Expand All @@ -58,42 +59,57 @@ app.get('/fetchReviews/dealer/:id', async (req, res) => {

// Express route to fetch all dealerships
app.get('/fetchDealers', async (req, res) => {
//Write your code here
try {
const documents = await Dealerships.find();
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

// Express route to fetch Dealers by a particular state
app.get('/fetchDealers/:state', async (req, res) => {
//Write your code here
try {
const documents = await Dealerships.find({ state: req.params.state });
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

// Express route to fetch dealer by a particular id
app.get('/fetchDealer/:id', async (req, res) => {
//Write your code here
try {
const documents = await Dealerships.find({ id: req.params.id });
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

//Express route to insert review
// Express route to insert review
app.post('/insert_review', express.raw({ type: '*/*' }), async (req, res) => {
data = JSON.parse(req.body);
const documents = await Reviews.find().sort( { id: -1 } )
let new_id = documents[0]['id']+1

const review = new Reviews({
"id": new_id,
"name": data['name'],
"dealership": data['dealership'],
"review": data['review'],
"purchase": data['purchase'],
"purchase_date": data['purchase_date'],
"car_make": data['car_make'],
"car_model": data['car_model'],
"car_year": data['car_year'],
});

try {
const data = JSON.parse(req.body);
const documents = await Reviews.find().sort({ id: -1 });
const new_id = documents[0].id + 1;

const review = new Reviews({
id: new_id,
name: data.name,
dealership: data.dealership,
review: data.review,
purchase: data.purchase,
purchase_date: data.purchase_date,
car_make: data.car_make,
car_model: data.car_model,
car_year: data.car_year,
});

const savedReview = await review.save();
res.json(savedReview);
} catch (error) {
console.log(error);
console.error(error);
res.status(500).json({ error: 'Error inserting review' });
}
});
Expand Down
29 changes: 15 additions & 14 deletions server/database/dealership.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
/*jshint esversion: 8 */
const mongoose = require('mongoose');

const Schema = mongoose.Schema;
const { Schema } = mongoose;

const dealerships = new Schema({
id: {
const dealershipSchema = new Schema({
id: {
type: Number,
required: true,
},
city: {
},
city: {
type: String,
required: true
required: true,
},
state: {
type: String,
required: true
required: true,
},
address: {
type: String,
required: true
required: true,
},
zip: {
type: String,
required: true
required: true,
},
lat: {
type: String,
required: true
required: true,
},
long: {
type: String,
required: true
required: true,
},
short_name: {
type: String,
},
full_name: {
type: String,
required: true
}
required: true,
},
});

module.exports = mongoose.model('dealerships', dealerships);
module.exports = mongoose.model('Dealership', dealershipSchema);
35 changes: 18 additions & 17 deletions server/database/inventory.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
/*jshint esversion: 8 */
const { Int32 } = require('mongodb');
const mongoose = require('mongoose');

const Schema = mongoose.Schema;
const { Schema } = mongoose;

const cars = new Schema({
dealer_id: {
const carSchema = new Schema({
dealer_id: {
type: Number,
required: true
},
make: {
required: true,
},
make: {
type: String,
required: true
required: true,
},
model: {
model: {
type: String,
required: true
required: true,
},
bodyType: {
bodyType: {
type: String,
required: true
required: true,
},
year: {
year: {
type: Number,
required: true
required: true,
},
mileage: {
mileage: {
type: Number,
required: true
}
required: true,
},
});

module.exports = mongoose.model('cars', cars);
module.exports = mongoose.model('Car', carSchema);
27 changes: 14 additions & 13 deletions server/database/review.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
/*jshint esversion: 8 */
const mongoose = require('mongoose');

const Schema = mongoose.Schema;
const { Schema } = mongoose;

const reviews = new Schema({
id: {
const reviewSchema = new Schema({
id: {
type: Number,
required: true,
},
name: {
},
name: {
type: String,
required: true
required: true,
},
dealership: {
type: Number,
required: true,
},
review: {
type: String,
required: true
required: true,
},
purchase: {
type: Boolean,
required: true
required: true,
},
purchase_date: {
type: String,
required: true
required: true,
},
car_make: {
type: String,
required: true
required: true,
},
car_model: {
type: String,
required: true
required: true,
},
car_year: {
type: Number,
required: true
required: true,
},
});

module.exports = mongoose.model('reviews', reviews);
module.exports = mongoose.model('Review', reviewSchema);
4 changes: 2 additions & 2 deletions server/djangoapp/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
backend_url =your backend url
sentiment_analyzer_url=your code engine deployment url
backend_url =https://abhijeetpadw-3030.theiadockernext-0-labs-prod-theiak8s-4-tor01.proxy.cognitiveclass.ai/
sentiment_analyzer_url=https://sentianalyzer.1nm6f9s0g2km.us-south.codeengine.appdomain.cloud/
13 changes: 5 additions & 8 deletions server/djangoapp/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# from django.contrib import admin
# from .models import related models
from django.contrib import admin
from .models import CarMake, CarModel


# Register your models here.

# CarModelInline class

# CarModelAdmin class
# Registering models with their respective admins
admin.site.register(CarMake)
admin.site.register(CarModel)

# CarMakeAdmin class with CarModelInline

Expand Down
Loading