hello everyone
Can anyone help me with it "let monthInSeconds : Int = 60 * 60 * 24 * 30;
type Key = { hash : K; key : K };
public query func groupAuctionsByMonth() : async Trie.Trie<Int, List.List> {
func getOverview(auction : Auction) : AuctionOverview = {
id = auction.id;
item = auction.item;
createdAt = auction.createdAt;
};
let highestBidAuction = List.map<Auction, AuctionOverview>(auctions, getOverview);
let a = List.toIter(highestBidAuction);
var monthlyAuctions : Trie.Trie<Int, List.List> = Trie.empty();
for (auction in a) {
let auctionMonth : Int = auction.createdAt / monthInSeconds;
let key : Key = {hash = auctionMonth; key = auctionMonth};
let isEqual = func(x : Int, y : Int) : Bool { x == y };
let result = Trie.find(monthlyAuctions, key, isEqual);
let monthAuctions = switch (Trie.find(monthlyAuctions, key, isEqual)) {
case (null) List.nil();
case (?auctions) auctions;
};
monthAuctions := List.push(auction, monthAuctions);
monthlyAuctions := Trie.replace(monthlyAuctions, auctionMonth, monthAuctions);
};
return monthlyAuctions;
};" here I need to get all auctions by dividing month