prod nginx changes and remove want on offer complete
This commit is contained in:
1 parent
2c66c47163
commit
644398319d
6 files changed
+52
-18
No files matched your search
@@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
push offers
|
push offers
|
||||||
cover off admin routes and commands
|
cover off admin routes and commands
|
||||||
|
remove want on offer complete
|
||||||
|
|
||||||
do we keep historical offers / wants?
|
do we keep historical offers / wants?
|
||||||
+12
-4
@@ -5,7 +5,7 @@ import groupBy from 'lodash/groupBy';
|
|||||||
import sortBy from 'lodash/sortBy';
|
import sortBy from 'lodash/sortBy';
|
||||||
import { Context } from 'koa';
|
import { Context } from 'koa';
|
||||||
|
|
||||||
import { logAxiosError } from './utils';
|
import { logAxiosError, wantDetails } from './utils';
|
||||||
import { Pg } from './pg';
|
import { Pg } from './pg';
|
||||||
|
|
||||||
export enum Status {
|
export enum Status {
|
||||||
@@ -65,9 +65,17 @@ export default function createOffers(log: Log, pg: Pg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function statusSet(user: User, id: UUID, status: Status) {
|
async function statusSet(user: User, id: UUID, status: Status) {
|
||||||
// check the user actually has this offer
|
log.info({ status, id }, 'setting offer status');
|
||||||
const offer = await pg.userOfferFind(user, id);
|
|
||||||
return pg.offerStatusSet(offer.id, status);
|
const offer = await pg.offerFindId(id);
|
||||||
|
const update = await pg.offerStatusSet(offer.id, status);
|
||||||
|
|
||||||
|
if (status === Status.Complete) {
|
||||||
|
log.info({ id, status }, 'completed offer, removing want...');
|
||||||
|
await pg.wantRm(offer.wantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return update;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bundles() {
|
async function bundles() {
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ export interface Pg {
|
|||||||
wantCreate: (discogsWant: any, user: User) => Promise<Want>,
|
wantCreate: (discogsWant: any, user: User) => Promise<Want>,
|
||||||
wantList: (user: User) => Promise<Want[]>,
|
wantList: (user: User) => Promise<Want[]>,
|
||||||
wantsToSync: () => Promise<Want[]>,
|
wantsToSync: () => Promise<Want[]>,
|
||||||
|
wantRm: (id: UUID) => Promise<void>,
|
||||||
|
|
||||||
bundleCandidates: () => Promise<Listing[][]>,
|
bundleCandidates: () => Promise<Listing[][]>,
|
||||||
|
|
||||||
offersCreate: (offers: Offer[]) => Promise<Offer[]>,
|
offersCreate: (offers: Offer[]) => Promise<Offer[]>,
|
||||||
offerStatusSet: (id: UUID, status: Status) => Promise<Offer>,
|
offerStatusSet: (id: UUID, status: Status) => Promise<Offer>,
|
||||||
offersAdmin: () => Promise<Offer[]>,
|
offersAdmin: () => Promise<Offer[]>,
|
||||||
|
offerFindId: (id: UUID) => Promise<Offer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function createPg(log: Log, prisma: PrismaClient): Pg {
|
export default function createPg(log: Log, prisma: PrismaClient): Pg {
|
||||||
@@ -60,6 +62,15 @@ export default function createPg(log: Log, prisma: PrismaClient): Pg {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function offerFindId(id: UUID) {
|
||||||
|
return prisma.offer.findFirstOrThrow({
|
||||||
|
where: { id },
|
||||||
|
include: {
|
||||||
|
want: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function userOfferFind(user: User, id: UUID) {
|
async function userOfferFind(user: User, id: UUID) {
|
||||||
return prisma.offer.findFirstOrThrow({
|
return prisma.offer.findFirstOrThrow({
|
||||||
where: {
|
where: {
|
||||||
@@ -86,6 +97,9 @@ export default function createPg(log: Log, prisma: PrismaClient): Pg {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// userUpdate({ email: 'jen@vdk.com', password: 'jen' });
|
||||||
|
// userUpdate({ email: 'james@mcd', password: 'james' });
|
||||||
|
|
||||||
async function userUpdate(params: UserCreateParams) {
|
async function userUpdate(params: UserCreateParams) {
|
||||||
const hashRounds = 10;
|
const hashRounds = 10;
|
||||||
const password = await bcrypt.hash(params.password, hashRounds);
|
const password = await bcrypt.hash(params.password, hashRounds);
|
||||||
@@ -111,6 +125,12 @@ export default function createPg(log: Log, prisma: PrismaClient): Pg {
|
|||||||
return prisma.want.findMany({});
|
return prisma.want.findMany({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function wantRm(id: UUID) {
|
||||||
|
await prisma.want.delete({
|
||||||
|
where: { id },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function wantCreate(discogsRelease, user) {
|
async function wantCreate(discogsRelease, user) {
|
||||||
const data: { userId: UUID, release: DiscogsListing, data: any } = {
|
const data: { userId: UUID, release: DiscogsListing, data: any } = {
|
||||||
data: discogsRelease,
|
data: discogsRelease,
|
||||||
@@ -286,6 +306,8 @@ export default function createPg(log: Log, prisma: PrismaClient): Pg {
|
|||||||
wantCreate,
|
wantCreate,
|
||||||
wantList,
|
wantList,
|
||||||
wantsToSync,
|
wantsToSync,
|
||||||
|
wantRm,
|
||||||
|
|
||||||
listingUpsert,
|
listingUpsert,
|
||||||
listingFind,
|
listingFind,
|
||||||
listingRmUnlisted,
|
listingRmUnlisted,
|
||||||
@@ -296,5 +318,6 @@ export default function createPg(log: Log, prisma: PrismaClient): Pg {
|
|||||||
offersCreate,
|
offersCreate,
|
||||||
offerStatusSet,
|
offerStatusSet,
|
||||||
offersAdmin,
|
offersAdmin,
|
||||||
|
offerFindId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
+3
-1
@@ -23,4 +23,6 @@ export function wantDetails(want: Want) {
|
|||||||
artist: data.artists_sort,
|
artist: data.artists_sort,
|
||||||
id: want.id
|
id: want.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function offerDetails() {}
|
||||||
@@ -5,6 +5,10 @@ import { useSelector, useDispatch } from 'react-redux'
|
|||||||
import http from './../http';
|
import http from './../http';
|
||||||
import { State, userState } from './../store';
|
import { State, userState } from './../store';
|
||||||
|
|
||||||
|
function showAdmin(user) {
|
||||||
|
return user && user.email === 'ntr@mnml.gg';
|
||||||
|
}
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const user = useSelector((state: State) => state.user);
|
const user = useSelector((state: State) => state.user);
|
||||||
@@ -48,7 +52,7 @@ const Header = () => {
|
|||||||
return (
|
return (
|
||||||
<header>
|
<header>
|
||||||
{user ? nav() : anonNav()}
|
{user ? nav() : anonNav()}
|
||||||
{user ? adminNav() : null}
|
{showAdmin(user) ? adminNav() : <div></div>}
|
||||||
{user ? userNav() : null}
|
{user ? userNav() : null}
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,16 +6,11 @@ upstream mcrates_client {
|
|||||||
server client:8080;
|
server client:8080;
|
||||||
}
|
}
|
||||||
|
|
||||||
# upstream mcrates_ws {
|
|
||||||
# server 127.0.0.1:40055;
|
|
||||||
# }
|
|
||||||
|
|
||||||
map $http_upgrade $connection_upgrade {
|
map $http_upgrade $connection_upgrade {
|
||||||
default upgrade;
|
default upgrade;
|
||||||
'' close;
|
'' close;
|
||||||
}
|
}
|
||||||
|
|
||||||
# DEV
|
|
||||||
server {
|
server {
|
||||||
server_name matescrates.au;
|
server_name matescrates.au;
|
||||||
|
|
||||||
@@ -30,13 +25,14 @@ server {
|
|||||||
proxy_read_timeout 600s;
|
proxy_read_timeout 600s;
|
||||||
}
|
}
|
||||||
|
|
||||||
# location /api/ws {
|
location /api/ws {
|
||||||
# proxy_pass http://mcrates_ws;
|
proxy_pass http://mcrates_api;
|
||||||
# proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
# proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
# proxy_set_header Connection $connection_upgrade;
|
proxy_set_header Connection $connection_upgrade;
|
||||||
# proxy_read_timeout 600s;
|
proxy_set_header Host $host;
|
||||||
# }
|
proxy_read_timeout 600s;
|
||||||
|
}
|
||||||
|
|
||||||
location /api/ {
|
location /api/ {
|
||||||
# trailing slash means api will receive url WITHOUT /api
|
# trailing slash means api will receive url WITHOUT /api
|
||||||
|
|||||||
Reference in new issue
Block a user