Skip to content

Commit 23d69cb

Browse files
Update version API for web manager
1 parent c4108b5 commit 23d69cb

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

web-server/pages/api/internal/version.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import axios from 'axios';
44
const dockerRepoName = 'middlewareeng/middleware';
55
const githubOrgName = 'middlewarehq';
66
const githubRepoName = 'middleware';
7-
const defaultBranch = 'main'
7+
const defaultBranch = 'main';
88

99
const endpoint = new Endpoint(nullSchema);
1010

@@ -114,22 +114,19 @@ async function fetchLatestGitHubCommit(): Promise<GitHubCommit> {
114114

115115
function isUpdateAvailable({
116116
localVersionInfo,
117-
dockerLatestRemoteTag,
118-
githubLatestCommit
117+
dockerLatestRemoteTag
119118
}: {
120119
localVersionInfo: ProjectVersionInfo;
121120
dockerLatestRemoteTag: TagCompressed;
122-
githubLatestCommit: GitHubCommit;
123121
}): boolean {
124122
const env = process.env.NEXT_PUBLIC_APP_ENVIRONMENT;
125123

126124
if (env == 'development') {
127-
const localBuildDate = new Date(localVersionInfo.current_build_date);
128-
const latestRemoteCommitDate = new Date(
129-
githubLatestCommit.commit.author.date
130-
);
131-
132-
return latestRemoteCommitDate > localBuildDate;
125+
const behindCommitsCount = process.env.BEHIND_COMMITS_COUNT
126+
? Number(process.env.BEHIND_COMMITS_COUNT)
127+
: 0;
128+
console.log('behindCommitsCount', behindCommitsCount);
129+
return behindCommitsCount > 0;
133130
}
134131

135132
const localBuildDate = new Date(localVersionInfo.current_build_date);
@@ -163,7 +160,6 @@ async function checkNewImageRelease(): Promise<CheckNewVersionResponse> {
163160
current_github_commit: versionInfo.merge_commit_sha,
164161
is_update_available: isUpdateAvailable({
165162
dockerLatestRemoteTag: latestTag,
166-
githubLatestCommit: githubLatestCommit,
167163
localVersionInfo: versionInfo
168164
}),
169165
latest_docker_image_build_date: latestRemoteDate

0 commit comments

Comments
 (0)