Skip to content

Add linting #169

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

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c062dab
Adding temporary changes to Github
Mar 29, 2025
fff0489
save this changes to github
Mar 29, 2025
9203b34
save this changes to github
Mar 29, 2025
0add5b1
save this changes to github
Mar 29, 2025
238fc28
save this changes to github
Mar 29, 2025
9744e01
save this changes to github
Mar 29, 2025
14d88b0
Create main.yml
upadhyaysaumya55 Mar 30, 2025
ae31d20
Delete .github/workflows/main.yml
upadhyaysaumya55 Mar 30, 2025
68a735e
Create main.yml
upadhyaysaumya55 Mar 30, 2025
1aee080
Delete .github/workflows directory
upadhyaysaumya55 Mar 30, 2025
da99def
Create main.yml
upadhyaysaumya55 Mar 30, 2025
8e0939c
Update app.js
upadhyaysaumya55 Mar 30, 2025
2123a9b
Update models.py
upadhyaysaumya55 Mar 30, 2025
2de73d9
Update models.py
upadhyaysaumya55 Mar 30, 2025
b57de9e
Update models.py
upadhyaysaumya55 Mar 30, 2025
cf8ae70
Update populate.py
upadhyaysaumya55 Mar 30, 2025
c6a6b13
Update restapis.py
upadhyaysaumya55 Mar 30, 2025
8879624
Update urls.py
upadhyaysaumya55 Mar 30, 2025
c595896
Update views.py
upadhyaysaumya55 Mar 30, 2025
51616eb
Update settings.py
upadhyaysaumya55 Mar 30, 2025
a215d21
Update urls.py
upadhyaysaumya55 Mar 30, 2025
f218830
Update inventory.js
upadhyaysaumya55 Mar 30, 2025
7d9eec2
Update dealership.js
upadhyaysaumya55 Mar 30, 2025
16cfaae
Update review.js
upadhyaysaumya55 Mar 30, 2025
56b7c2f
Update app.js
upadhyaysaumya55 Mar 30, 2025
48263cb
Delete .github/workflows directory
upadhyaysaumya55 Mar 30, 2025
912c626
Create main.yml
upadhyaysaumya55 Mar 30, 2025
542e3de
save this changes to github
Mar 30, 2025
d130cf3
save this changes to github
Mar 30, 2025
1ebeebd
save this changes to github
Mar 30, 2025
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
57 changes: 57 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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"
25 changes: 25 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.12.0-slim-bookworm

ENV PYTHONBUFFERED 1
ENV PYTHONWRITEBYTECODE 1

ENV APP=/app

# Change the workdir.
WORKDIR $APP

# Install the requirements
COPY requirements.txt $APP

RUN pip3 install -r requirements.txt

# Copy the rest of the files
COPY . $APP

EXPOSE 8000

RUN chmod +x /app/entrypoint.sh

ENTRYPOINT ["/bin/bash","/app/entrypoint.sh"]

CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangoproj.wsgi"]
13 changes: 13 additions & 0 deletions server/carsInventory/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:18.12.1-bullseye-slim

RUN npm install -g [email protected]

ADD package.json .
ADD app.js .
ADD data/car_records.json .
COPY . .
RUN npm install

EXPOSE 3050

CMD [ "node", "app.js" ]
125 changes: 125 additions & 0 deletions server/carsInventory/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*jshint esversion: 8 */

const express = require('express');
const mongoose = require('mongoose');
const fs = require('fs');
const cors = require('cors');

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

app.use(cors());
app.use(express.urlencoded({ extended: false }));

const carsData = JSON.parse(fs.readFileSync('car_records.json', 'utf8'));

mongoose.connect('mongodb://mongo_db:27017/', { dbName: 'dealershipsDB' })
.then(() => console.log('MongoDB connected'))
.catch(err => console.error('MongoDB connection error:', err));


const Cars = require('./inventory');

try {

Cars.deleteMany({}).then(() => {
Cars.insertMany(carsData.cars);
});
} catch (error) {
console.error(error);
// Handle errors properly here
}

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



app.get('/cars/:id', async (req, res) => {
try {
const documents = await Cars.find({dealer_id: req.params.id});
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching reviews' });
}
});

app.get('/carsbymake/:id/:make', async (req, res) => {
try {
const documents = await Cars.find({dealer_id: req.params.id, make: req.params.make});
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching reviews by car make and model' });
}
});

app.get('/carsbymodel/:id/:model', async (req, res) => {
try {
const documents = await Cars.find({ dealer_id: req.params.id, model: req.params.model });
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching dealers by ID' });
}
});

app.get('/carsbymaxmileage/:id/:mileage', async (req, res) => {
try {
let mileage = parseInt(req.params.mileage)
let condition = {}
if(mileage === 50000) {
condition = { $lte : mileage}
} else if (mileage === 100000){
condition = { $lte : mileage, $gt : 50000}
} else if (mileage === 150000){
condition = { $lte : mileage, $gt : 100000}
} else if (mileage === 200000){
condition = { $lte : mileage, $gt : 150000}
} else {
condition = { $gt : 200000}
}
const documents = await Cars.find({ dealer_id: req.params.id, mileage : condition });
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching dealers by ID' });
}
});


app.get('/carsbyprice/:id/:price', async (req, res) => {
try {
let price = parseInt(req.params.price)
let condition = {}
if(price === 20000) {
condition = { $lte : price}
} else if (price=== 40000){
console.log("\n \n \n "+ price)
condition = { $lte : price, $gt : 20000}
} else if (price === 60000){
condition = { $lte : price, $gt : 40000}
} else if (price === 80000){
condition = { $lte : price, $gt : 60000}
} else {
condition = { $gt : 80000}
}
const documents = await Cars.find({ dealer_id: req.params.id, price : condition });
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching dealers by ID' });
}
});



app.get('/carsbyyear/:id/:year', async (req, res) => {
try {
const documents = await Cars.find({ dealer_id: req.params.id, year : { $gte :req.params.year }});
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching dealers by ID' });
}
});

app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
Loading