Skip to content

Commit aa106da

Browse files
authored
Merge pull request #627 from internetarchive/improved-suggestion
Improved suggestions
2 parents 7db724d + f8fb2ae commit aa106da

4 files changed

Lines changed: 30 additions & 5 deletions

File tree

bin/deploy-to-alexa-skill.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,23 @@ cp ./functions/index-alexa.js ./deploy/alexa/index-alexa.js
1919
cp ./functions/package.json ./deploy/alexa/package.json
2020
# aws-sdk is already available in AWS Lambda running the app, we delete it to
2121
# reduce the filesize because the unzipped code must be < 250MB
22-
# `npm install -g node-prune` is required
23-
(cd ./deploy/alexa/; npm install --production; rm -rf node_modules/aws-sdk; node-prune node_modules)
24-
# TODO show size of unzipped (it should be less then 250M)
22+
# `npm install -g node-prune` is required (optional but recommended)
23+
echo -e "$checkit installing dependencies"
24+
(cd ./deploy/alexa/; npm install --omit=dev --legacy-peer-deps; rm -rf node_modules/aws-sdk)
25+
# Check if node-prune is available and use it if present
26+
if command -v node-prune &> /dev/null; then
27+
echo -e "$checkit pruning node_modules"
28+
(cd ./deploy/alexa/; node-prune node_modules)
29+
else
30+
echo -e "⚠️ node-prune not found (optional). Install with: npm install -g node-prune"
31+
fi
32+
# Check size of unzipped (should be less than 250MB)
33+
UNZIPPED_SIZE=$(du -sm ./deploy/alexa | cut -f1)
34+
echo -e "$checkit unzipped size: ${UNZIPPED_SIZE}MB"
35+
if [ "$UNZIPPED_SIZE" -gt 250 ]; then
36+
echo "⚠️ WARNING: Unzipped size (${UNZIPPED_SIZE}MB) exceeds 250MB AWS Lambda limit!"
37+
echo " Consider using node-prune or removing unnecessary dependencies"
38+
fi
2539

2640
# zip files
2741
echo -e "$checkit zip files"

functions/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "audio-interface-of-internet-archive",
33
"description": "Audio Interface of Internet Archive",
4-
"version": "2.5.18",
4+
"version": "2.5.19",
55
"private": true,
66
"author": "Internet Archive",
77
"license": "AGPL-3.0",

functions/src/actions/_middlewares/song-data.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,28 @@ const mapSongDataToSlots = ({ type = 'current' } = {}) => (ctx) => {
3535
return Promise.reject(new EmptySongDataError(ctx, 'there is no song data'));
3636
}
3737

38+
// Preserve original coverage and year from user's selection if they exist,
39+
// so the response matches what the user selected rather than what the album has
40+
const originalCoverage = slots.coverage;
41+
const originalYear = slots.year;
42+
3843
// we need to escape song data because they could have special symbols
3944
// like < or > but we should do it only for speech because it uses SSML
4045
const slotsWithEscapedSongDetails = {
4146
...slots,
4247
...escapeHTMLObject(song, { skipFields: ['audioURL', 'imageURL'] }),
48+
// Preserve user-selected coverage and year
49+
...(originalCoverage && { coverage: originalCoverage }),
50+
...(originalYear && { year: originalYear }),
4351
};
4452

4553
// in all other cases we could have these special symbols
4654
const slotsWithOriginalSongDetails = {
4755
...slots,
4856
...song,
57+
// Preserve user-selected coverage and year to ensure response matches user's selection
58+
...(originalCoverage && { coverage: originalCoverage }),
59+
...(originalYear && { year: originalYear }),
4960
};
5061

5162
const playbackUIScheme = selectors.find(availableStrings, slotsWithOriginalSongDetails);

0 commit comments

Comments
 (0)