mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-12-23 20:15:13 +00:00
Compare commits
No commits in common. "3eea4f7f726451a56c3a5910c7c0d52a9ed8e630" and "c8cbc53c914ece1d0f9c699e367d6a509eeb3351" have entirely different histories.
3eea4f7f72
...
c8cbc53c91
|
@ -89,7 +89,7 @@ contactpersonsRouter.post('/', async (req: Request, res: Response) => {
|
||||||
const success = await ContactPersonService.createContactEntry(user.user_id, vendor_id, first_name, last_name, gender, email, phone);
|
const success = await ContactPersonService.createContactEntry(user.user_id, vendor_id, first_name, last_name, gender, email, phone);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.sendStatus(201);
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
res.sendStatus(500);
|
res.sendStatus(500);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,11 +85,11 @@ pricealarmsRouter.put('/', async (req: Request, res: Response) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update price alarm
|
// Create price alarm
|
||||||
const success = await PriceAlarmsService.updatePriceAlarm(alarm_id, user.user_id, defined_price);
|
const success = await PriceAlarmsService.updatePriceAlarm(alarm_id, user.user_id, defined_price);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.status(200).send(JSON.stringify({success: true}));
|
res.status(201).send(JSON.stringify({success: true}));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send(JSON.stringify({success: false}));
|
res.status(500).send(JSON.stringify({success: false}));
|
||||||
|
|
|
@ -117,7 +117,7 @@ pricesRouter.post('/', async (req: Request, res: Response) => {
|
||||||
const success = await PriceService.createPriceEntry(user.user_id, vendor_id, product_id, price_in_cents);
|
const success = await PriceService.createPriceEntry(user.user_id, vendor_id, product_id, price_in_cents);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.sendStatus(201);
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
res.sendStatus(500);
|
res.sendStatus(500);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the session details back to the user
|
// Send the session details back to the user
|
||||||
res.status(200).send(user);
|
res.status(201).send(user);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
# Base image
|
# Base image
|
||||||
FROM python:3.9.5-buster
|
FROM python
|
||||||
|
|
||||||
# Create directories and copy files
|
# Create directories and copy files
|
||||||
RUN echo 'Creating directory and copying files'
|
RUN echo 'Creating directory and copying files'
|
||||||
RUN mkdir /crawler
|
RUN mkdir /crawler
|
||||||
COPY . /crawler
|
ADD . /crawler
|
||||||
WORKDIR /crawler
|
WORKDIR /crawler
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
export interface Category {
|
|
||||||
category_id: number;
|
|
||||||
name: string;
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
export interface ContactPerson {
|
|
||||||
contact_person_id: number;
|
|
||||||
first_name: string;
|
|
||||||
last_name: string;
|
|
||||||
gender: string;
|
|
||||||
email: string;
|
|
||||||
phone: string;
|
|
||||||
vendor_id: number;
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
export interface CrawlingStatus {
|
|
||||||
process_id: number;
|
|
||||||
started_timestamp: Date;
|
|
||||||
combinations_to_crawl: number;
|
|
||||||
successful_crawls: number;
|
|
||||||
failed_crawls: number;
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
export interface Manufacturer {
|
|
||||||
manufacturer_id: number;
|
|
||||||
name: string;
|
|
||||||
}
|
|
|
@ -7,10 +7,6 @@ import {Observable, of} from 'rxjs';
|
||||||
import {Vendor} from '../models/vendor';
|
import {Vendor} from '../models/vendor';
|
||||||
import {PriceAlarm} from '../models/pricealarm';
|
import {PriceAlarm} from '../models/pricealarm';
|
||||||
import {FavoriteShop} from '../models/favoriteshop';
|
import {FavoriteShop} from '../models/favoriteshop';
|
||||||
import {ContactPerson} from '../models/contactperson';
|
|
||||||
import {Category} from '../models/category';
|
|
||||||
import {Manufacturer} from '../models/manufacturer';
|
|
||||||
import {CrawlingStatus} from '../models/crawlingstatus';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -385,216 +381,4 @@ export class ApiService {
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ______ __ __ ____
|
|
||||||
/ ____/___ ____ / /_____ ______/ /_ / __ \___ ______________ ____ _____
|
|
||||||
/ / / __ \/ __ \/ __/ __ `/ ___/ __/ / /_/ / _ \/ ___/ ___/ __ \/ __ \/ ___/
|
|
||||||
/ /___/ /_/ / / / / /_/ /_/ / /__/ /_ / ____/ __/ / (__ ) /_/ / / / (__ )
|
|
||||||
\____/\____/_/ /_/\__/\__,_/\___/\__/ /_/ \___/_/ /____/\____/_/ /_/____/
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of all contact persons
|
|
||||||
* @return Observable<ContactPerson[]> An observable list of contact persons
|
|
||||||
*/
|
|
||||||
getContactPersons(): Observable<ContactPerson[]> {
|
|
||||||
try {
|
|
||||||
return this.http.get<ContactPerson[]>((this.apiUrl + '/contactpersons'));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the specified contact person by id
|
|
||||||
* @param id the id of the contact person to get info about
|
|
||||||
* @return Observable<ContactPerson> An observable containing a single contact person
|
|
||||||
*/
|
|
||||||
getContactPersonById(id: number): Observable<ContactPerson> {
|
|
||||||
try {
|
|
||||||
return this.http.get<ContactPerson>((this.apiUrl + '/contactpersons/' + id));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the contact persons for the specified vendor
|
|
||||||
* @param vendorId the id of the vendor to get the contact persons for
|
|
||||||
* @return Observable<ContactPerson[]> An observable list of contact persons
|
|
||||||
*/
|
|
||||||
getContactPersonsByVendor(vendorId: number): Observable<ContactPerson[]> {
|
|
||||||
try {
|
|
||||||
return this.http.get<ContactPerson[]>((this.apiUrl + '/contactpersons/byvendor/' + vendorId));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a contact person for the specified vendor
|
|
||||||
* @param vendorId The id of the vendor to mark as favorite
|
|
||||||
* @param firstName The given name of the contact person
|
|
||||||
* @param lastName The family name of the contact person
|
|
||||||
* @param gender The gender of the contact person
|
|
||||||
* @param email The email address of the contact person
|
|
||||||
* @param phone The phone number of the contact person
|
|
||||||
* @return Observable<any> The observable response of the api
|
|
||||||
*/
|
|
||||||
addContactPerson(vendorId: number, firstName: string, lastName: string, gender: string, email: string, phone: string): Observable<any> {
|
|
||||||
try {
|
|
||||||
return this.http.post((this.apiUrl + '/contactpersons'), JSON.stringify({
|
|
||||||
vendor_id: vendorId,
|
|
||||||
first_name: firstName,
|
|
||||||
last_name: lastName,
|
|
||||||
gender,
|
|
||||||
email,
|
|
||||||
phone
|
|
||||||
}));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the specified contact person record
|
|
||||||
* @param contactId The id of the contact person record
|
|
||||||
* @param vendorId The id of the vendor to mark as favorite
|
|
||||||
* @param firstName The given name of the contact person
|
|
||||||
* @param lastName The family name of the contact person
|
|
||||||
* @param gender The gender of the contact person
|
|
||||||
* @param email The email address of the contact person
|
|
||||||
* @param phone The phone number of the contact person
|
|
||||||
* @return Observable<any> The observable response of the api
|
|
||||||
*/
|
|
||||||
updateContactPerson(contactId: number, vendorId: number, firstName: string, lastName: string, gender: string, email: string, phone: string): Observable<any> {
|
|
||||||
try {
|
|
||||||
return this.http.put((this.apiUrl + '/contactpersons/' + contactId), JSON.stringify({
|
|
||||||
vendor_id: vendorId,
|
|
||||||
first_name: firstName,
|
|
||||||
last_name: lastName,
|
|
||||||
gender,
|
|
||||||
email,
|
|
||||||
phone
|
|
||||||
}));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ______ __ _
|
|
||||||
/ ____/___ _/ /____ ____ _____ _____(_)__ _____
|
|
||||||
/ / / __ `/ __/ _ \/ __ `/ __ \/ ___/ / _ \/ ___/
|
|
||||||
/ /___/ /_/ / /_/ __/ /_/ / /_/ / / / / __(__ )
|
|
||||||
\____/\__,_/\__/\___/\__, /\____/_/ /_/\___/____/
|
|
||||||
/____/
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the specified category from the API
|
|
||||||
* @param id The id of the category to get
|
|
||||||
* @return Observable<Category> An observable containing a single category
|
|
||||||
*/
|
|
||||||
getCategoryById(id: number): Observable<Category> {
|
|
||||||
try {
|
|
||||||
return this.http.get<Category>((this.apiUrl + '/categories/' + id));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of categories that match the given search term
|
|
||||||
* @param query The search term to match
|
|
||||||
* @return Observable<Category[]> An observable list of categories
|
|
||||||
*/
|
|
||||||
getCategoriesByQuery(query: string): Observable<Category[]> {
|
|
||||||
try {
|
|
||||||
return this.http.get<Category[]>((this.apiUrl + '/categories/search/' + query));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of all categories
|
|
||||||
* @return Observable<Category[]> An observable list of categories
|
|
||||||
*/
|
|
||||||
getCategories(): Observable<Category[]> {
|
|
||||||
try {
|
|
||||||
return this.http.get<Category[]>((this.apiUrl + '/categories'));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* __ ___ ____ __
|
|
||||||
/ |/ /___ _____ __ __/ __/___ ______/ /___ __________ __________
|
|
||||||
/ /|_/ / __ `/ __ \/ / / / /_/ __ `/ ___/ __/ / / / ___/ _ \/ ___/ ___/
|
|
||||||
/ / / / /_/ / / / / /_/ / __/ /_/ / /__/ /_/ /_/ / / / __/ / (__ )
|
|
||||||
/_/ /_/\__,_/_/ /_/\__,_/_/ \__,_/\___/\__/\__,_/_/ \___/_/ /____/
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the specified manufacturer from the API
|
|
||||||
* @param id The id of the manufacturer to get
|
|
||||||
* @return Observable<Manufacturer> An observable containing a single manufacturer
|
|
||||||
*/
|
|
||||||
getManufacturerById(id: number): Observable<Manufacturer> {
|
|
||||||
try {
|
|
||||||
return this.http.get<Manufacturer>((this.apiUrl + '/manufacturers/' + id));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of manufacturers that match the given search term
|
|
||||||
* @param query The search term to match
|
|
||||||
* @return Observable<Manufacturer[]> An observable list of manufacturers
|
|
||||||
*/
|
|
||||||
getManufacturersByQuery(query: string): Observable<Manufacturer[]> {
|
|
||||||
try {
|
|
||||||
return this.http.get<Manufacturer[]>((this.apiUrl + '/manufacturers/search/' + query));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of all manufacturers
|
|
||||||
* @return Observable<Manufacturer[]> An observable list of manufacturer
|
|
||||||
*/
|
|
||||||
getManufacturers(): Observable<Manufacturer[]> {
|
|
||||||
try {
|
|
||||||
return this.http.get<Manufacturer[]>((this.apiUrl + '/manufacturers'));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ______ ___ _____ __ __
|
|
||||||
/ ____/________ __ __/ (_)___ ____ _ / ___// /_____ _/ /___ _______
|
|
||||||
/ / / ___/ __ `/ | /| / / / / __ \/ __ `/ \__ \/ __/ __ `/ __/ / / / ___/
|
|
||||||
/ /___/ / / /_/ /| |/ |/ / / / / / / /_/ / ___/ / /_/ /_/ / /_/ /_/ (__ )
|
|
||||||
\____/_/ \__,_/ |__/|__/_/_/_/ /_/\__, / /____/\__/\__,_/\__/\__,_/____/
|
|
||||||
/____/
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current crawling status
|
|
||||||
* @return Observable<CrawlingStatus> An observable containing a single crawling status object
|
|
||||||
*/
|
|
||||||
getCurrentCrawlingStatus(): Observable<CrawlingStatus> {
|
|
||||||
try {
|
|
||||||
return this.http.get<CrawlingStatus>((this.apiUrl + '/crawlingstatus'));
|
|
||||||
} catch (exception) {
|
|
||||||
process.stderr.write(`ERROR received from ${this.apiUrl}: ${exception}\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ Wiki: https://github.com/Mueller-Patrick/Betterzon/wiki
|
||||||
|
|
||||||
# Code Quality
|
# Code Quality
|
||||||
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/88e47ebf837b43af9d12147c22f77f7f)](https://www.codacy.com/gh/Mueller-Patrick/Betterzon/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Mueller-Patrick/Betterzon&utm_campaign=Badge_Grade)
|
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/88e47ebf837b43af9d12147c22f77f7f)](https://www.codacy.com/gh/Mueller-Patrick/Betterzon/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Mueller-Patrick/Betterzon&utm_campaign=Badge_Grade)
|
||||||
[![Code Coverage](https://img.shields.io/badge/coverage-82%25-green)](https://ci.betterzon.xyz)
|
|
||||||
|
|
||||||
# Project Status
|
# Project Status
|
||||||
[![Website Status](https://img.shields.io/website?label=www.betterzon.xyz&style=for-the-badge&url=https%3A%2F%2Fwww.betterzon.xyz)](https://www.betterzon.xyz)
|
[![Website Status](https://img.shields.io/website?label=www.betterzon.xyz&style=for-the-badge&url=https%3A%2F%2Fwww.betterzon.xyz)](https://www.betterzon.xyz)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user