@@ -113,108 +113,105 @@ public Result<Collection<ScreenshotData>> allOf(final Set<Long> pks) {
113113
114114 @ Override
115115 @ Transactional (readOnly = true )
116- public Result <Collection <ScreenshotData >> allOfSession (final String sessionUUID ) {
116+ public Result <Collection <ScreenshotDataRecord >> allOfSession (final String sessionUUID ) {
117117 return Result .tryCatch (() -> this .screenshotDataRecordMapper .selectByExample ()
118118 .where (ScreenshotDataRecordDynamicSqlSupport .sessionUuid , SqlBuilder .isEqualTo (sessionUUID ))
119119 .build ()
120- .execute ()
121- .stream ()
122- .map (this ::toDomainModel )
123- .collect (Collectors .toList ()));
120+ .execute ());
124121 }
125122
126- @ Override
127- @ Transactional (readOnly = true )
128- public Result <ScreenshotDataRecord > getAt (final String sessionUUID , final Long at ) {
129-
130- System .out .print ("******************** getAt called for session: " + sessionUUID + " with at: " + at );
131-
132- // TODO: this seems to produce performance issues when table is huge. Try to optimize query by reducing the time frame here
133- return Result .tryCatch (() -> {
134- ScreenshotDataRecord record = SelectDSL
135- .selectWithMapper (this .screenshotDataRecordMapper ::selectOne ,
136- id ,
137- sessionUuid ,
138- timestamp ,
139- imageFormat ,
140- metaData ,
141- timestamp )
142- .from (screenshotDataRecord )
143- .where (ScreenshotDataRecordDynamicSqlSupport .sessionUuid , SqlBuilder .isEqualTo (sessionUUID ))
144- .and (ScreenshotDataRecordDynamicSqlSupport .timestamp , SqlBuilder .isLessThanOrEqualTo (at ))
145- .orderBy (timestamp .descending ())
146- .limit (1 )
147- .build ()
148- .execute ();
149-
150- if (record != null ) {
151- return record ;
152- }
153-
154- // there is no screenshot at the time of given timestamp. Try to get first image for the session
155- record = SelectDSL
156- .selectWithMapper (this .screenshotDataRecordMapper ::selectOne ,
157- id ,
158- sessionUuid ,
159- timestamp ,
160- imageFormat ,
161- metaData ,
162- timestamp )
163- .from (screenshotDataRecord )
164- .where (ScreenshotDataRecordDynamicSqlSupport .sessionUuid , SqlBuilder .isEqualTo (sessionUUID ))
165- .orderBy (timestamp )
166- .limit (1 )
167- .build ()
168- .execute ();
169-
170- // still no screenshot... seems that there are none at this time
171- if (record == null ) {
172- throw new NoResourceFoundException (EntityType .SCREENSHOT_DATA , sessionUUID );
173- }
174-
175- return record ;
176- });
177- }
178-
179- @ Override
180- @ Transactional (readOnly = true )
181- public Result <Long > getIdAt (final String sessionUUID , final Long at ) {
182- return Result .tryCatch (() -> {
183-
184- System .out .println ("******************** getIdAt called for session: " + sessionUUID + " with at: " + at );
185-
186- List <Long > result = SelectDSL
187- .selectWithMapper (this .screenshotDataRecordMapper ::selectIds , id , timestamp )
188- .from (screenshotDataRecord )
189- .where (ScreenshotDataRecordDynamicSqlSupport .sessionUuid , SqlBuilder .isEqualTo (sessionUUID ))
190- .and (ScreenshotDataRecordDynamicSqlSupport .timestamp , SqlBuilder .isLessThanOrEqualTo (at ))
191- .orderBy (timestamp .descending ())
192- .limit (1 )
193- .build ()
194- .execute ();
195-
196- if (result != null && !result .isEmpty ()) {
197- return result .get (0 );
198- }
199-
200- // there is no screenshot at the time of given timestamp. Try to get first image for the session
201- result = SelectDSL
202- .selectWithMapper (this .screenshotDataRecordMapper ::selectIds , id , timestamp )
203- .from (screenshotDataRecord )
204- .where (ScreenshotDataRecordDynamicSqlSupport .sessionUuid , SqlBuilder .isEqualTo (sessionUUID ))
205- .orderBy (timestamp )
206- .limit (1 )
207- .build ()
208- .execute ();
209-
210- // still no screenshot... seems that there are none at this time
211- if (result == null || result .isEmpty ()) {
212- throw new NoResourceFoundException (EntityType .SCREENSHOT_DATA , sessionUUID );
213- }
123+ // @Override
124+ // @Transactional(readOnly = true)
125+ // public Result<ScreenshotDataRecord> getAt(final String sessionUUID, final Long at) {
126+ //
127+ // System.out.print("******************** getAt called for session: " + sessionUUID + " with at: " + at);
128+ //
129+ // // TODO: this seems to produce performance issues when table is huge. Try to optimize query by reducing the time frame here
130+ // return Result.tryCatch(() -> {
131+ // ScreenshotDataRecord record = SelectDSL
132+ // .selectWithMapper(this.screenshotDataRecordMapper::selectOne,
133+ // id,
134+ // sessionUuid,
135+ // timestamp,
136+ // imageFormat,
137+ // metaData,
138+ // timestamp)
139+ // .from(screenshotDataRecord)
140+ // .where(ScreenshotDataRecordDynamicSqlSupport.sessionUuid, SqlBuilder.isEqualTo(sessionUUID))
141+ // .and(ScreenshotDataRecordDynamicSqlSupport.timestamp, SqlBuilder.isLessThanOrEqualTo(at))
142+ // .orderBy(timestamp.descending())
143+ // .limit(1)
144+ // .build()
145+ // .execute();
146+ //
147+ // if (record != null) {
148+ // return record;
149+ // }
150+ //
151+ // // there is no screenshot at the time of given timestamp. Try to get first image for the session
152+ // record = SelectDSL
153+ // .selectWithMapper(this.screenshotDataRecordMapper::selectOne,
154+ // id,
155+ // sessionUuid,
156+ // timestamp,
157+ // imageFormat,
158+ // metaData,
159+ // timestamp)
160+ // .from(screenshotDataRecord)
161+ // .where(ScreenshotDataRecordDynamicSqlSupport.sessionUuid, SqlBuilder.isEqualTo(sessionUUID))
162+ // .orderBy(timestamp)
163+ // .limit(1)
164+ // .build()
165+ // .execute();
166+ //
167+ // // still no screenshot... seems that there are none at this time
168+ // if (record == null) {
169+ // throw new NoResourceFoundException(EntityType.SCREENSHOT_DATA, sessionUUID);
170+ // }
171+ //
172+ // return record;
173+ // });
174+ // }
214175
215- return result .get (0 );
216- });
217- }
176+ // @Override
177+ // @Transactional(readOnly = true)
178+ // public Result<Long> getIdAt(final String sessionUUID, final Long at) {
179+ // return Result.tryCatch(() -> {
180+ //
181+ // System.out.println("******************** getIdAt called for session: " + sessionUUID + " with at: " + at);
182+ //
183+ // List<Long> result = SelectDSL
184+ // .selectWithMapper(this.screenshotDataRecordMapper::selectIds, id, timestamp)
185+ // .from(screenshotDataRecord)
186+ // .where(ScreenshotDataRecordDynamicSqlSupport.sessionUuid, SqlBuilder.isEqualTo(sessionUUID))
187+ // .and(ScreenshotDataRecordDynamicSqlSupport.timestamp, SqlBuilder.isLessThanOrEqualTo(at))
188+ // .orderBy(timestamp.descending())
189+ // .limit(1)
190+ // .build()
191+ // .execute();
192+ //
193+ // if (result != null && !result.isEmpty()) {
194+ // return result.get(0);
195+ // }
196+ //
197+ // // there is no screenshot at the time of given timestamp. Try to get first image for the session
198+ // result = SelectDSL
199+ // .selectWithMapper(this.screenshotDataRecordMapper::selectIds, id, timestamp)
200+ // .from(screenshotDataRecord)
201+ // .where(ScreenshotDataRecordDynamicSqlSupport.sessionUuid, SqlBuilder.isEqualTo(sessionUUID))
202+ // .orderBy(timestamp)
203+ // .limit(1)
204+ // .build()
205+ // .execute();
206+ //
207+ // // still no screenshot... seems that there are none at this time
208+ // if (result == null || result.isEmpty()) {
209+ // throw new NoResourceFoundException(EntityType.SCREENSHOT_DATA, sessionUUID);
210+ // }
211+ //
212+ // return result.get(0);
213+ // });
214+ // }
218215
219216// @Override
220217// @Transactional(readOnly = true)
0 commit comments