-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Harmonize TrackLog and ClientError (#344)
+ Fixes #342
- Loading branch information
1 parent
e1c11ff
commit a373055
Showing
7 changed files
with
143 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
grails-app/services/io/xh/hoist/clienterror/ClientErrorAdminService.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.xh.hoist.clienterror | ||
|
||
import grails.gorm.transactions.ReadOnly | ||
import io.xh.hoist.BaseService | ||
import io.xh.hoist.data.filter.Filter | ||
import io.xh.hoist.track.TrackLog | ||
import org.hibernate.Criteria | ||
import org.hibernate.SessionFactory | ||
|
||
import java.time.LocalDate | ||
|
||
import static io.xh.hoist.util.DateTimeUtils.appEndOfDay | ||
import static io.xh.hoist.util.DateTimeUtils.appStartOfDay | ||
import static org.hibernate.criterion.Order.desc | ||
import static org.hibernate.criterion.Restrictions.between | ||
|
||
class ClientErrorAdminService extends BaseService { | ||
SessionFactory sessionFactory | ||
|
||
@ReadOnly | ||
List<ClientError> queryClientError(LocalDate startDay, LocalDate endDay, Filter filter, int maxRows) { | ||
def session = sessionFactory.currentSession | ||
Criteria c = session.createCriteria(ClientError) | ||
c.maxResults = maxRows | ||
c.addOrder(desc('dateCreated')) | ||
c.add(between('dateCreated', appStartOfDay(startDay), appEndOfDay(endDay))) | ||
if (filter) { | ||
c.add(filter.criterion) | ||
} | ||
c.list() as List<ClientError> | ||
} | ||
|
||
@ReadOnly | ||
Map lookups() {[ | ||
browser: distinctVals('browser'), | ||
device: distinctVals('device'), | ||
username: distinctVals('username'), | ||
appEnvironment: distinctVals('appEnvironment') | ||
] } | ||
|
||
//------------------------ | ||
// Implementation | ||
//------------------------ | ||
private List distinctVals(String property) { | ||
ClientError.createCriteria().list { | ||
projections { distinct(property) } | ||
}.sort() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters