Skip to content

Commit 1989b88

Browse files
authored
Merge pull request #257 from smartdevicelink/feature/message-versioning
Add non-static consumer message versioning
2 parents 641a656 + 3ef0003 commit 1989b88

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

app/v1/messages/sql.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ module.exports = {
2222
categoryByLanguage: getMessageCategoriesByLanguage,
2323
categoryByMaxId: getMessageCategoriesByMaxId,
2424
byIds: getMessagesByIdsStagingFilter,
25-
groupsByIds: getMessageGroupsByIdsStagingFilter
25+
groupsByIds: getMessageGroupsByIdsStagingFilter,
26+
highestGroupId: getHighestMessageGroupId,
2627
},
2728
getMessageNamesStaging: getMessageNamesStaging,
2829
getLanguages: getLanguages,
@@ -44,6 +45,16 @@ function getMessagesStatus (isProduction) {
4445
}
4546
}
4647

48+
//retrieve the highest id message group found
49+
function getHighestMessageGroupId (isProduction) {
50+
let viewName = isProduction ? 'view_message_group_production' : 'view_message_group_staging';
51+
52+
let sqlString = sql.select('MAX(id) AS id')
53+
.from(viewName);
54+
55+
return sqlString.toString();
56+
}
57+
4758
//retrieve message group information such as categories
4859
function getMessageGroups (isProduction, category, hideDeleted = false) {
4960
let viewName = isProduction ? 'view_message_group_production' : 'view_message_group_staging';

app/v1/policy/helper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ function setupModuleConfig (isProduction, useLongUuids = false) {
119119
function setupConsumerFriendlyMessages (isProduction) {
120120
const getMessages = flame.flow({
121121
messageStatuses: setupSqlCommand.bind(null, messagesSql.getMessages.status(isProduction)),
122-
messageGroups: setupSqlCommand.bind(null, messagesSql.getMessages.group(isProduction, false, true))
122+
messageGroups: setupSqlCommand.bind(null, messagesSql.getMessages.group(isProduction, false, true)),
123+
highestMessageGroupId: setupSqlCommand.bind(null, messagesSql.getMessages.highestGroupId(isProduction, false))
123124
}, {method: 'parallel'});
124125

125126
const makeMessages = [

app/v1/policy/model.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ function transformModuleConfig (isProduction, useLongUuids = false, info, next)
127127
function transformMessages (info, cb) {
128128
const allMessages = info.messageStatuses;
129129
const groups = info.messageGroups;
130+
const highestMessageGroupId = info.highestMessageGroupId[0] ? info.highestMessageGroupId[0].id : 0; // used to help generate a version number
131+
const versionString = Number(highestMessageGroupId).toLocaleString().replace(/,/g,'.').padStart(11, "000."); // ###.###.### format up to the id of 999,999,999
130132

131133
const transformFlow = flame.flow([
132134
//hash the message groups by message_category
@@ -159,7 +161,7 @@ function transformMessages (info, cb) {
159161
next();
160162
}, function () {
161163
next(null, {
162-
"version": "000.000.001", //TODO: what to do with the versioning?
164+
"version": versionString,
163165
"messages": messageObj
164166
});
165167
});

0 commit comments

Comments
 (0)