Skip to content

Commit

Permalink
fix on query
Browse files Browse the repository at this point in the history
  • Loading branch information
chopperdaddy committed Jun 12, 2023
1 parent 1b55ae0 commit f7771e1
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions frontend/src/app/services/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@ import { BehaviorSubject, map, Subscription, tap } from 'rxjs';

import { Auction, Bid } from '../interfaces/auction';

const GET_AUCTIONS = gql`
{
auctions(
orderBy: startTime
orderDirection: desc
first: 500
) {
phunk { id }
id
startTime
endTime
settled
amount
# attributes
# image
bidder {
id
}
bids {
id
bidder { id }
amount,
blockTimestamp
}
}
}
`;

@Injectable({
providedIn: 'root'
})
Expand All @@ -26,40 +54,12 @@ export class DataService {
}

getAuctionData(): void {

const GET_AUCTIONS = gql`
{
auctions(
orderBy: startTime,
orderDirection: desc
) {
phunk { id }
id
startTime
endTime
settled
amount
# attributes
# image
bidder {
id
}
bids {
id
bidder { id }
amount,
blockTimestamp
}
}
}
`;

this.subscription = this.apollo.query({ query: GET_AUCTIONS }).pipe(
map((res: any) => res.data?.auctions || []),
// tap(console.log),
map((res: any[]) => {
const auctions: Auction[] = res.map((auction: any) => {
const bids: Bid[] = [...auction?.bids].sort((a: Bid, b: Bid) => Number(b?.amount) - Number(a?.amount));
const bids: Bid[] = [ ...auction?.bids ].sort((a: Bid, b: Bid) => Number(b?.amount) - Number(a?.amount));
return {
id: auction.id,
phunkId: auction?.phunk.id,
Expand Down Expand Up @@ -101,4 +101,4 @@ export class DataService {
});
}

}
}

0 comments on commit f7771e1

Please sign in to comment.