Last active
November 25, 2022 21:38
-
-
Save lonniev/26e3cbfb85189ef4604d591b6059e6bc to your computer and use it in GitHub Desktop.
Perform a Gremlin Query that looks up who changed a particular thread and when
This file contains hidden or 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
userName = { u,t -> userGet = new URL( "http://syndeia.company.com:9000/users/${u}" ).openConnection(); userGet.setRequestProperty( "Accept", "application/json" ); userGet.setRequestProperty( "X-Auth-Token", t ); userGet.getResponseCode(); j = new groovy.json.JsonSlurper().parseText( userGet.getInputStream().getText() ); j.resources.name } | |
signInToken = { -> signInPost = new URL( "http://syndeia.company.com:9000/signIn" ).openConnection(); message = '{ "username": "[email protected]", "password": "pass-phrase", "rememberMe": false }'; signInPost.setDoOutput( true ); signInPost.setRequestProperty( "Content-Type", "application/json" ); signInPost.getOutputStream().write( message.getBytes( "UTF-8" ) ); signInPost.getResponseCode(); j = new groovy.json.JsonSlurper().parseText( signInPost.getInputStream().getText() ); j.resources.token } | |
g.E().has( 'Relation', 'container', 'DZSB19' ) | |
.group() | |
.by( values( 'modifiedDate' ) | |
.map{ ( LocalDateTime.parse( it.get(), java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME ) ) | |
.format( java.time.format.DateTimeFormatter.ofPattern( "YYYY MM/dd EEEE" ) ) } ) | |
.by( groupCount().by( values( 'modifiedBy' ) ) ) | |
.unfold() | |
.order().by( keys ) | |
.project( 'When', 'Who' ) | |
.by( select( keys ) ) | |
.by( select( values ).unfold() | |
.map{ it -> "${userName( it.get().getKey(), signInToken() )} (${it.get().getValue()} times)" }.fold() ) |
Author
lonniev
commented
Sep 1, 2022
•
- the threads of a Syndeia Project are all within a particular container
- these are then grouped
- by the modifiedDate
- which is first mapped to a human-friendly format
- by who made the modification
- which is first grouped by user id and counted
- this is unfolded or spread back to a sequence
- that is ordered by the modification date string
- which is output as When and Who
- by the key (day)
- by the value (who and count)
- and the user id is mapped from an internal identifier to a human user name via an external authenticated REST call
- by the modifiedDate
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment