Skip to content

Commit

Permalink
fix: deployment db queries
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Jul 17, 2018
1 parent 0e79a17 commit b81f9ea
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/in-house-bot/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1204,11 +1204,7 @@ ${this.genUsageInstructions(links)}`
public getVersionInfoByTag = async (tag: string):Promise<VersionInfo> => {
if (tag === 'latest') return this.getLatestVersionInfo()

return await this.bot.db.findOne({
orderBy: {
property: '_time',
desc: true
},
const { items } = await this.bot.db.find({
filter: {
EQ: {
[TYPE]: VERSION_INFO,
Expand All @@ -1217,6 +1213,8 @@ ${this.genUsageInstructions(links)}`
}
}
})

return _.maxBy(items, '_time')
}

public getLatestVersionInfo = async ():Promise<VersionInfo> => {
Expand All @@ -1237,11 +1235,7 @@ ${this.genUsageInstructions(links)}`
}

public getUpdateByTag = async (tag: string) => {
return await this.bot.db.findOne({
orderBy: {
property: '_time',
desc: true
},
const { items } = await this.bot.db.find({
filter: {
EQ: {
[TYPE]: UPDATE,
Expand All @@ -1250,6 +1244,8 @@ ${this.genUsageInstructions(links)}`
}
}
})

return _.maxBy(items, '_time')
}

public includesUpdate = (updateTag: string) => {
Expand Down Expand Up @@ -1596,4 +1592,7 @@ const shouldSendVersionAlert = (versionInfo: VersionInfo) => {
return ALERT_BRANCHES.includes(versionInfo.branch)
}

const sortVersions = (items: any[]) => _.sortBy(items, ['sortableTag', '_time'])
const sortVersions = (items: any[], desc?: boolean) => {
const sorted = _.sortBy(items, ['sortableTag', '_time'])
return desc ? sorted.reverse() : sorted
}

0 comments on commit b81f9ea

Please sign in to comment.