@@ -65,59 +65,55 @@ export async function findEnvironmentById(id: string) {
65
65
}
66
66
67
67
export async function createNewSession ( environment : RuntimeEnvironment , ipAddress : string ) {
68
- return prisma . $transaction ( async ( tx ) => {
69
- const session = await tx . runtimeEnvironmentSession . create ( {
70
- data : {
71
- environmentId : environment . id ,
72
- ipAddress,
73
- } ,
74
- } ) ;
75
-
76
- await tx . runtimeEnvironment . update ( {
77
- where : {
78
- id : environment . id ,
79
- } ,
80
- data : {
81
- currentSessionId : session . id ,
82
- } ,
83
- } ) ;
84
-
85
- return session ;
68
+ const session = await prisma . runtimeEnvironmentSession . create ( {
69
+ data : {
70
+ environmentId : environment . id ,
71
+ ipAddress,
72
+ } ,
73
+ } ) ;
74
+
75
+ await prisma . runtimeEnvironment . update ( {
76
+ where : {
77
+ id : environment . id ,
78
+ } ,
79
+ data : {
80
+ currentSessionId : session . id ,
81
+ } ,
86
82
} ) ;
83
+
84
+ return session ;
87
85
}
88
86
89
87
export async function disconnectSession ( environmentId : string ) {
90
- return prisma . $transaction ( async ( tx ) => {
91
- const environment = await tx . runtimeEnvironment . findUnique ( {
92
- where : {
93
- id : environmentId ,
94
- } ,
95
- } ) ;
96
-
97
- if ( ! environment || ! environment . currentSessionId ) {
98
- return null ;
99
- }
88
+ const environment = await prisma . runtimeEnvironment . findUnique ( {
89
+ where : {
90
+ id : environmentId ,
91
+ } ,
92
+ } ) ;
100
93
101
- const session = await tx . runtimeEnvironmentSession . update ( {
102
- where : {
103
- id : environment . currentSessionId ,
104
- } ,
105
- data : {
106
- disconnectedAt : new Date ( ) ,
107
- } ,
108
- } ) ;
109
-
110
- await tx . runtimeEnvironment . update ( {
111
- where : {
112
- id : environment . id ,
113
- } ,
114
- data : {
115
- currentSessionId : null ,
116
- } ,
117
- } ) ;
118
-
119
- return session ;
94
+ if ( ! environment || ! environment . currentSessionId ) {
95
+ return null ;
96
+ }
97
+
98
+ const session = await prisma . runtimeEnvironmentSession . update ( {
99
+ where : {
100
+ id : environment . currentSessionId ,
101
+ } ,
102
+ data : {
103
+ disconnectedAt : new Date ( ) ,
104
+ } ,
120
105
} ) ;
106
+
107
+ await prisma . runtimeEnvironment . update ( {
108
+ where : {
109
+ id : environment . id ,
110
+ } ,
111
+ data : {
112
+ currentSessionId : null ,
113
+ } ,
114
+ } ) ;
115
+
116
+ return session ;
121
117
}
122
118
123
119
type DisplayableInputEnvironment = Prisma . RuntimeEnvironmentGetPayload < {
0 commit comments