Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #580

Merged
merged 5 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/workflows/infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,6 @@ jobs:
runs-on: ubuntu-latest
needs: [build_server, build_gds, build_grs]
env:
COMMAND_MONGO_URL: ${{ secrets.COMMAND_MONGO_URL }}
COMMAND_MONGO_DB: ${{ secrets.COMMAND_MONGO_DB }}
COMMAND_MONGO_USER: ${{ secrets.COMMAND_MONGO_USER }}
COMMAND_MONGO_PASS: ${{ secrets.COMMAND_MONGO_PASS }}
COMMAND_MONGO_AUTH_DB: ${{ secrets.COMMAND_MONGO_AUTH_DB }}
RABBIT_URL: ${{ secrets.RABBIT_URL }}
TIMESERIES_HOST: ${{ secrets.TIMESERIES_HOST }}
TIMESERIES_PASSWORD: ${{ secrets.TIMESERIES_PASSWORD }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
steps:
- name: checkout
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/supporting-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ jobs:
runs-on: ubuntu-latest
needs: [ build_mqtt_auth_server ]
env:
COMMAND_MONGO_URL: ${{ secrets.COMMAND_MONGO_URL }}
COMMAND_MONGO_DB: ${{ secrets.COMMAND_MONGO_DB }}
COMMAND_MONGO_USER: ${{ secrets.COMMAND_MONGO_USER }}
COMMAND_MONGO_PASS: ${{ secrets.COMMAND_MONGO_PASS }}
COMMAND_MONGO_AUTH_DB: ${{ secrets.COMMAND_MONGO_AUTH_DB }}
RABBIT_URL: ${{ secrets.RABBIT_URL }}
TIMESERIES_HOST: ${{ secrets.TIMESERIES_HOST }}
TIMESERIES_PASSWORD: ${{ secrets.TIMESERIES_PASSWORD }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
steps:
- name: checkout
Expand Down
Binary file not shown.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.4.15-alpha.309](https://github.com/TheTechCompany/HiveCommandClient/compare/v1.4.15-alpha.308...v1.4.15-alpha.309) (2024-04-29)

**Note:** Version bump only for package @hivecomand-clients/root





## [1.4.15-alpha.308](https://github.com/TheTechCompany/HiveCommandClient/compare/v1.4.15-alpha.307...v1.4.15-alpha.308) (2024-04-22)

**Note:** Version bump only for package @hivecomand-clients/root





## [1.4.15-alpha.307](https://github.com/TheTechCompany/HiveCommandClient/compare/v1.4.15-alpha.306...v1.4.15-alpha.307) (2024-04-10)

**Note:** Version bump only for package @hivecomand-clients/root
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"packages/types/*"
],
"npmClient": "yarn",
"version": "1.4.15-alpha.307"
"version": "1.4.15-alpha.309"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ts-jest": "^27.0.7"
},
"dependencies": {
"@apollo/client": "^3.8.1",
"@apollo/client": "3.9",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@hexhive/styles": "^1.0.1-alpha.65",
Expand Down
16 changes: 16 additions & 0 deletions packages/app/hivecommand-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.4.15-alpha.309](https://github.com/TheTechCompany/HiveCommand/compare/v1.4.15-alpha.308...v1.4.15-alpha.309) (2024-04-29)

**Note:** Version bump only for package @hive-command/api





## [1.4.15-alpha.308](https://github.com/TheTechCompany/HiveCommand/compare/v1.4.15-alpha.307...v1.4.15-alpha.308) (2024-04-22)

**Note:** Version bump only for package @hive-command/api





## [1.4.15-alpha.307](https://github.com/TheTechCompany/HiveCommand/compare/v1.4.15-alpha.306...v1.4.15-alpha.307) (2024-04-10)

**Note:** Version bump only for package @hive-command/api
Expand Down
4 changes: 2 additions & 2 deletions packages/app/hivecommand-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hive-command/api",
"version": "1.4.15-alpha.307",
"version": "1.4.15-alpha.309",
"description": "",
"main": "dist/index.js",
"private": true,
Expand All @@ -27,7 +27,7 @@
"lodash": "^4.17.21"
},
"peerDependencies": {
"@apollo/client": "^3.8.1",
"@apollo/client": "3.9",
"react": "*"
}
}
16 changes: 16 additions & 0 deletions packages/app/hivecommand-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.4.15-alpha.309](https://github.com/TheTechCompany/HiveCommand/compare/v1.4.15-alpha.308...v1.4.15-alpha.309) (2024-04-29)

**Note:** Version bump only for package @hive-command/backend





## [1.4.15-alpha.308](https://github.com/TheTechCompany/HiveCommand/compare/v1.4.15-alpha.307...v1.4.15-alpha.308) (2024-04-22)

**Note:** Version bump only for package @hive-command/backend





## [1.4.15-alpha.307](https://github.com/TheTechCompany/HiveCommand/compare/v1.4.15-alpha.306...v1.4.15-alpha.307) (2024-04-10)

**Note:** Version bump only for package @hive-command/backend
Expand Down
2 changes: 0 additions & 2 deletions packages/app/hivecommand-backend/__tests__/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,3 @@ const text = ts.transpileModule(`

});


console.log({text})
6 changes: 3 additions & 3 deletions packages/app/hivecommand-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hive-command/backend",
"version": "1.4.15-alpha.307",
"version": "1.4.15-alpha.309",
"description": "",
"main": "index.js",
"private": true,
Expand Down Expand Up @@ -39,8 +39,8 @@
"@casl/ability": "^6.5.0",
"@graphql-tools/merge": "^9.0.0",
"@hexhive/graphql-server": "1.0.2-beta.70",
"@hive-command/amqp-client": "^1.4.15-alpha.307",
"@hive-command/data": "^1.4.15-alpha.307",
"@hive-command/amqp-client": "^1.4.15-alpha.309",
"@hive-command/data": "^1.4.15-alpha.309",
"@hive-command/scripting": "^1.4.15-alpha.289",
"@prisma/client": "^3.12.0",
"amqplib": "^0.8.0",
Expand Down
59 changes: 1 addition & 58 deletions packages/app/hivecommand-backend/src/schema/devices/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,9 @@ export default (prisma: PrismaClient) => {
const resolvers = {
CommandDeviceAnalytic: {
values: async (root: any, args: {startDate: Date, endDate?: Date, format?: string}) => {


let query = ``;

let params = [root.page?.device?.id, root.tag?.id]
// console.log("Analaytics values")

const afterTime = args.startDate ? moment(args.startDate) : undefined;

Expand Down Expand Up @@ -160,14 +157,7 @@ export default (prisma: PrismaClient) => {
console.log({e})
}

// const result = await client.query(
// query,
// params
// )

// console.log("Analaytics values")

// await client.release()


},
totalValue: async (root: any, args: any, context: any) => {
Expand All @@ -183,53 +173,6 @@ export default (prisma: PrismaClient) => {
if(beforeTime && moment(beforeTime).isAfter(moment())){
beforeTime = moment();
}

// const session = driver.session()

//TODO get time dimension

// const unitResult = await session.run(`
// MATCH (:CommandDevice {id: $id})-[:RUNNING_PROGRAM]->(:CommandProgram)-[:USES_DEVICE]->(device:CommandProgramDevicePlaceholder {name: $name})-[:USES_TEMPLATE]->()-->(stateItem:CommandProgramDeviceState {key: $key})
// OPTIONAL MATCH (device)-[:MAPS_UNIT]->(unitConfig:CommandProgramDeviceUnit)-[:MAPS_STATE_UNIT]->(stateItem)
// RETURN unitConfig{.*}
// `, { id: deviceId, name: device, key: valueKey })

// const unitConfig = unitResult.records?.[0]?.get(0)

// let timeDimension = 60; //divide value by 60 to go from minutes to seconds, divide by 3,600 to go from hours to seconds

// console.log({unitConfig})
// if(unitConfig && (unitConfig.displayUnit || unitConfig.inputUnit)){
// let unitRegex = /(.+)\/(.+)/
// let [ fullText, unit, dimension ] = (unitConfig.displayUnit ? unitConfig.displayUnit.match(unitRegex) : unitConfig.inputUnit.match(unitRegex)) || [];


// if(dimension != undefined){
// try{
// let timeUnit = mathUnit(dimension).to('seconds');
// console.log("Found", {unit, dimension})

// timeDimension = timeUnit.toNumber()
// console.log({timeDimension})
// }catch(e) {
// console.error("Could not parse time unit", {unit, dimension, e})
// }
// }

// }

/*

(

*





*/


const { unit } = root;
let unitTimeDimension = 60; //60 = minutedata, 60 * 60 = hrdata, 60 * 60 * 24 = daydata
Expand Down
70 changes: 3 additions & 67 deletions packages/app/hivecommand-backend/src/schema/devices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,7 @@ import { subject } from '@casl/ability'

const Moniker = require('moniker')

const withCancel = (asyncIterator: AsyncIterator<any>, onCancel: () => void) => {
const asyncReturn = asyncIterator.return;

asyncIterator.return = () => {
console.log("Async Cancel")
onCancel();
return asyncReturn ? asyncReturn.call(asyncIterator) : Promise.resolve({ value: undefined, done: true });
};

return asyncIterator;
};

// //TODO move this out of memory
// const watching = {

// }

export default (prisma: PrismaClient) => {

const {typeDefs: analyticTypeDefs, resolvers: analyticResolvers} = analytics(prisma)
Expand All @@ -40,7 +25,6 @@ export default (prisma: PrismaClient) => {
{
DeviceAlarm: {
ack: (root: any) => {
// console.log({root})
return root.ackBy?.id != null && root.ackBy?.id != undefined
}
},
Expand Down Expand Up @@ -113,37 +97,12 @@ export default (prisma: PrismaClient) => {
value: results?.[r]
}
})
// //Get data from mongocache
// result = await prisma.deviceValue.findMany({
// where: {
// deviceId: root.id,
// },
// orderBy: {
// lastUpdated: 'desc'
// },
// distinct: ['deviceId', 'placeholder', 'key']
// })

// result = await cache.DeviceValue.find({
// deviceId: root.id
// });

}
// console.log(await cache.DeviceValue.find())


return result;

// return await prisma.$queryRaw`
// SELECT latest.* FROM (
// SELECT DISTINCT placeholder, key, "deviceId", MAX("lastUpdated") as latest FROM "DeviceValue"
// WHERE "deviceId"=${root.id}
// GROUP BY placeholder, key, "deviceId"
// ) AS uniq
// JOIN "DeviceValue" latest ON uniq.placeholder = latest.placeholder
// AND uniq."deviceId" = latest."deviceId"
// AND uniq.latest = latest."lastUpdated"
// AND uniq.key = latest.key
// `
}
},
Query: {
Expand Down Expand Up @@ -299,8 +258,6 @@ export default (prisma: PrismaClient) => {
Subscription: {
watchingDevice: {
subscribe: async (root: any, args: any, context: GraphQLContext) => {
console.log("Subscribe to watchingDevice", {args, pubSub: context.pubSub})

const redisTag = `watchingDevice:${args.device}`

const iter = context.pubSub.asyncIterator(`${redisTag}-channel`);
Expand All @@ -318,7 +275,6 @@ export default (prisma: PrismaClient) => {

const ttl = await context.redis.ttl(`${redisTag}:${(context as any)?.jwt?.id}`);

console.log({ttl})
}, 30 * 1000)
})
// await co ntext.redis.sAdd(redisTag, (context as any)?.jwt?.id)
Expand All @@ -329,31 +285,23 @@ export default (prisma: PrismaClient) => {
MATCH: `${redisTag}:*`,
COUNT: 0,
})){
// console.log({key})
watching.push(key.match(/(.+):(.+):(.+)/)?.[3])
}


// const items = await context.redis.scan(0, [`${redisTag}:*`]);

// console.log({items});

// const watching = await context.redis.sMembers(redisTag)
setTimeout(async () => {
await context.pubSub.publish(`${redisTag}-channel`, {watchers: watching.map((x) => ({id: x}))})
}, 100);

const asyncReturn = iter.return;

iter.return = async () => {
console.log("Cancel");

clearInterval(interval);

const redisTag = `watchingDevice:${args.device}`

const count = await context.redis.decr(`${redisTag}:${(context as any)?.jwt?.id}`)
console.log({count})

if(count <= 0){
await context.redis.del([`${redisTag}:${(context as any)?.jwt?.id}`])

Expand All @@ -364,7 +312,6 @@ export default (prisma: PrismaClient) => {
MATCH: `${redisTag}:*`,
COUNT: 0,
})){
// console.log({key})
watching.push(key.match(/(.+):(.+):(.+)/)?.[3])
}

Expand All @@ -376,20 +323,9 @@ export default (prisma: PrismaClient) => {
}

return iter
// withCancel(iter, async () => {
// console.log("Unsubscribe", {context, args})
// const redisTag = `watchingDevice:${args.device}`

// await context.redis.sRem(redisTag, (context as any)?.jwt?.id)

// const watching = await context.redis.sMembers(redisTag)

// await context.pubSub.publish(`${redisTag}-channel`, {watchers: watching.map((x) => ({id: x}))})

// }) //context.pubSub.asyncIterator("watchingDevice");
},
resolve: (payload: any) => {
console.log("Send new info", {payload})
return payload.watchers;
}
}
Expand Down
Loading
Loading