Skip to content

Commit

Permalink
Added sort-by-name to Marketplace sale collaborators
Browse files Browse the repository at this point in the history
  • Loading branch information
wlara committed Sep 17, 2024
1 parent 4dc2c68 commit 06f8ccc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MarketplaceSaleEntity(
fun toModel(
isMainnet: Boolean,
isNftCdnEnabled: Boolean,
costAmountConvertions: CostAmountConversions
costAmountConversions: CostAmountConversions
): Sale {
val song = SongEntity[songId]
val artist = UserEntity[song.ownerId]
Expand All @@ -77,16 +77,14 @@ class MarketplaceSaleEntity(
if (isNftCdnEnabled) {
val fingerprint = assetFingerprintOf(song.nftPolicyId!!, song.nftName!!)
coverArtUrl = nftCdnRepository.generateImageUrl(fingerprint)
clipUrl =
nftCdnRepository.generateFileUrl(
fingerprint = fingerprint,
index = mintingRepository.getAudioClipFileIndex(song.nftPolicyId!!)
)
tokenAgreementUrl =
nftCdnRepository.generateFileUrl(
fingerprint = fingerprint,
index = mintingRepository.getTokenAgreementFileIndex(song.nftPolicyId!!)
)
clipUrl = nftCdnRepository.generateFileUrl(
fingerprint = fingerprint,
index = mintingRepository.getAudioClipFileIndex(song.nftPolicyId!!)
)
tokenAgreementUrl = nftCdnRepository.generateFileUrl(
fingerprint = fingerprint,
index = mintingRepository.getTokenAgreementFileIndex(song.nftPolicyId!!)
)
} else {
coverArtUrl = release.arweaveCoverArtUrl!!.arweaveToWebUrl()
clipUrl = song.arweaveClipUrl!!.arweaveToWebUrl()
Expand All @@ -101,39 +99,39 @@ class MarketplaceSaleEntity(
costPolicyId = costPolicyId,
costAssetName = costAssetName,
costAmount = costAmount,
costAmountUsd = costAmountConvertions.usd,
costAmountNewm = costAmountConvertions.newm,
costAmountUsd = costAmountConversions.usd,
costAmountNewm = costAmountConversions.newm,
maxBundleSize = maxBundleSize,
totalBundleQuantity = totalBundleQuantity,
bundleAmount = bundleAmount,
availableBundleQuantity = availableBundleQuantity,
song =
Sale.Song(
id = songId.value,
artistId = artist.id.value,
artistName = artist.stageOrFullName,
artistPictureUrl = artist.pictureUrl,
title = song.title,
description = song.description,
parentalAdvisory = song.parentalAdvisory,
genres = song.genres.toList(),
moods = song.moods?.toList(),
coverArtUrl = coverArtUrl,
clipUrl = clipUrl,
tokenAgreementUrl = tokenAgreementUrl,
assetUrl = assetUrlOf(isMainnet, song.nftPolicyId!!, song.nftName!!),
collaborators =
CollaborationEntity.findBySongId(songId.value).mapNotNull { collab ->
UserEntity.getByEmail(collab.email)?.run {
Sale.SongCollaborator(
id = id.value,
name = stageOrFullName,
pictureUrl = pictureUrl,
role = collab.role
)
}
song = Sale.Song(
id = songId.value,
artistId = artist.id.value,
artistName = artist.stageOrFullName,
artistPictureUrl = artist.pictureUrl,
title = song.title,
description = song.description,
parentalAdvisory = song.parentalAdvisory,
genres = song.genres.toList(),
moods = song.moods?.toList(),
coverArtUrl = coverArtUrl,
clipUrl = clipUrl,
tokenAgreementUrl = tokenAgreementUrl,
assetUrl = assetUrlOf(isMainnet, song.nftPolicyId!!, song.nftName!!),
collaborators = CollaborationEntity
.findBySongId(songId.value)
.mapNotNull { collab ->
UserEntity.getByEmail(collab.email)?.run {
Sale.SongCollaborator(
id = id.value,
name = stageOrFullName,
pictureUrl = pictureUrl,
role = collab.role
)
}
)
}.sortedBy { it.name },
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ class MarketplaceRoutesTests : BaseApplicationTests() {
}.toModel(
isMainnet = false,
isNftCdnEnabled = false,
costAmountConvertions = CostAmountConversions(
costAmountConversions = CostAmountConversions(
usd = costAmountUsd.toBigDecimal(12).toPlainString(),
newm = (costAmountUsd.toBigDecimal(6) / NEWM_USD_PRICE.toBigDecimal()).toPlainString()
)
Expand Down

0 comments on commit 06f8ccc

Please sign in to comment.