Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
UPHRH-lms-service
Commits
901cacbe
Unverified
Commit
901cacbe
authored
4 years ago
by
Mahesh Kumar Gangula
Committed by
GitHub
4 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #333 from manjudr/summary-api-fix
Collection summary api granularity query issue fix
parents
077cad56
46950645
master
bootcamp
dependabot/maven/course-mw/course-actors-common/com.fasterxml.jackson.core-jackson-databind-2.12.7.1
dependabot/maven/course-mw/course-actors-common/org.postgresql-postgresql-42.4.1
dependabot/maven/course-mw/enrolment-actor/com.fasterxml.jackson.core-jackson-databind-2.12.7.1
dependabot/maven/course-mw/sunbird-util/sunbird-cassandra-utils/com.fasterxml.jackson.core-jackson-databind-2.12.7.1
dependabot/maven/course-mw/sunbird-util/sunbird-notification/com.fasterxml.jackson.core-jackson-databind-2.12.7.1
dependabot/maven/course-mw/sunbird-util/sunbird-notification/org.apache.httpcomponents-httpclient-4.5.13
dependabot/maven/course-mw/sunbird-util/sunbird-platform-core/actor-core/com.fasterxml.jackson.core-jackson-databind-2.12.7.1
dependabot/maven/course-mw/sunbird-util/sunbird-platform-core/actor-util/com.fasterxml.jackson.core-jackson-databind-2.12.7.1
dependabot/maven/course-mw/sunbird-util/sunbird-platform-core/auth-verifier/com.fasterxml.jackson.core-jackson-databind-2.12.7.1
dependabot/maven/course-mw/sunbird-util/sunbird-platform-core/common-util/com.fasterxml.jackson.core-jackson-databind-2.12.7.1
dependabot/maven/course-mw/sunbird-util/sunbird-platform-core/common-util/junit-junit-4.13.1
dependabot/maven/course-mw/sunbird-util/sunbird-platform-core/common-util/org.apache.httpcomponents-httpclient-4.5.13
dependabot/maven/course-mw/sunbird-util/sunbird-platform-core/common-util/org.apache.kafka-kafka-clients-0.10.2.2
dependabot/maven/course-mw/sunbird-util/sunbird-platform-core/common-util/org.apache.tika-tika-core-1.22
dependabot/maven/course-mw/sunbird-util/sunbird-platform-core/common-util/org.jboss.resteasy-resteasy-client-3.14.0.Final
dependabot/maven/service/com.fasterxml.jackson.core-jackson-databind-2.12.7.1
dependabot/maven/service/junit-junit-4.13.1
dependabot/maven/service/org.apache.httpcomponents-httpclient-4.5.13
helmchart
release-3.7.0
release-5.0.0
release-5.0.1
release-5.0.2
release-5.1.0
release-5.2.0
release-5.2.1
release-5.3.0
release-5.3.1
release-5.4.0
release-5.3.1_RC1
release-5.3.0_RC1
release-5.2.0_RC2
release-5.2.0_RC1
release-5.1.0_RC2
release-5.1.0_RC1
release-5.0.1_RC3
release-5.0.1_RC2
release-5.0.1_RC1
release-5.0.0_RC6
release-5.0.0_RC5
release-5.0.0_RC4
release-5.0.0_RC3
release-5.0.0_RC2
release-5.0.0_RC1
release-3.7.0_RC4
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
course-mw/enrolment-actor/src/main/scala/org/sunbird/aggregate/CollectionSummaryAggregate.scala
+15
-12
...la/org/sunbird/aggregate/CollectionSummaryAggregate.scala
with
15 additions
and
12 deletions
+15
-12
course-mw/enrolment-actor/src/main/scala/org/sunbird/aggregate/CollectionSummaryAggregate.scala
+
15
−
12
View file @
901cacbe
...
...
@@ -39,6 +39,7 @@ class CollectionSummaryAggregate @Inject()(implicit val cacheUtil: RedisCacheUti
val
collectionId
=
filters
.
get
(
JsonKey
.
COLLECTION_ID
).
asInstanceOf
[
String
]
val
granularity
=
getDate
(
request
.
getRequestContext
,
request
.
getRequest
.
getOrDefault
(
"granularity"
,
"ALL"
).
asInstanceOf
[
String
],
collectionId
,
batchId
)
val
key
=
getCacheKey
(
batchId
=
batchId
,
granularity
,
groupByKeys
)
println
(
s
"Druid granularity: $granularity & Cache Key: $key"
)
try
{
val
redisData
=
cacheUtil
.
get
(
key
)
val
result
:
util.Map
[
String
,
AnyRef
]
=
if
(
null
!=
redisData
&&
!
redisData
.
isEmpty
)
{
...
...
@@ -194,8 +195,7 @@ class CollectionSummaryAggregate @Inject()(implicit val cacheUtil: RedisCacheUti
| ]
| }
|}"""
.
stripMargin
.
replaceAll
(
"null"
,
" "
)
ProjectLogger
.
log
(
"Druid Query Is "
+
druidQuery
)
println
(
"Query"
+
druidQuery
)
println
(
"Druid Query"
+
JsonUtil
.
serialize
(
druidQuery
))
val
host
:
String
=
if
(
StringUtils
.
isNotBlank
(
ProjectUtil
.
getConfigValue
(
"druid_proxy_api_host"
)))
ProjectUtil
.
getConfigValue
(
"druid_proxy_api_host"
)
else
"localhost"
val
port
:
String
=
if
(
StringUtils
.
isNotBlank
(
ProjectUtil
.
getConfigValue
(
"druid_proxy_api_port"
)))
ProjectUtil
.
getConfigValue
(
"druid_proxy_api_port"
)
else
"8081"
val
endPoint
:
String
=
if
(
StringUtils
.
isNotBlank
(
ProjectUtil
.
getConfigValue
(
"druid_proxy_api_endpoint"
)))
ProjectUtil
.
getConfigValue
(
"druid_proxy_api_endpoint"
)
else
"/druid/v2/"
...
...
@@ -217,18 +217,21 @@ class CollectionSummaryAggregate @Inject()(implicit val cacheUtil: RedisCacheUti
}
def
getDate
(
requestContext
:
RequestContext
,
date
:
String
,
courseId
:
String
,
batchId
:
String
)
:
String
=
{
val
dateTimeFormat
e
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
)
// When e
ndate
is null in the table considering default date as 7
val
default
End
Date
=
dateTimeFormat
e
.
print
(
DateTime
.
now
(
DateTimeZone
.
UTC
)
.
minusDays
(
7
)
)
val
dateTimeFormat
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd"
)
val
defaultE
nd
D
ate
=
dateTimeFormat
.
print
(
DateTime
.
now
(
DateTimeZone
.
UTC
).
plusDays
(
1
))
// Adding 1 Day extra
val
default
Start
Date
=
dateTimeFormat
.
print
(
DateTime
.
now
(
DateTimeZone
.
UTC
))
val
nofDates
=
date
.
replaceAll
(
"[^0-9]"
,
""
)
val
endDate
=
dateTimeFormate
.
print
(
DateTime
.
now
(
DateTimeZone
.
UTC
).
plusDays
(
1
))
// Adding 1 Day extra
val
startDate
:
String
=
if
(!
StringUtils
.
equalsIgnoreCase
(
date
,
"ALL"
))
{
dateTimeFormate
.
print
(
DateTime
.
now
(
DateTimeZone
.
UTC
).
minusDays
(
nofDates
.
toInt
))
if
(
StringUtils
.
equalsIgnoreCase
(
date
,
"ALL"
))
{
// When granularity Is ALL fetch the batch start and end date.
val
courseBatchData
=
courseBatchDao
.
readById
(
courseId
,
batchId
,
requestContext
)
val
batchStartDate
=
Option
(
courseBatchData
.
getStartDate
)
.
map
(
date
=>
if
(
date
.
isEmpty
)
defaultStartDate
else
date
).
getOrElse
(
defaultStartDate
)
val
batchEndDate
=
Option
(
courseBatchData
.
getEndDate
)
.
map
(
date
=>
if
(
date
.
isEmpty
)
defaultEndDate
else
date
).
getOrElse
(
defaultEndDate
)
s
"$batchStartDate/$batchEndDate"
}
else
{
val
batchEndDate
=
courseBatchDao
.
readById
(
courseId
,
batchId
,
requestContext
).
getEndDate
logger
.
debug
(
requestContext
,
s
"BatchId: $batchId, CourseId: $courseId, EndDate"
+
batchEndDate
)
Option
(
batchEndDate
).
map
(
date
=>
if
(
date
.
isEmpty
)
defaultEndDate
else
date
).
getOrElse
(
defaultEndDate
)
val
startDate
=
dateTimeFormat
.
print
(
DateTime
.
now
(
DateTimeZone
.
UTC
).
minusDays
(
nofDates
.
toInt
))
s
"$startDate/$defaultEndDate"
}
s
"$startDate/$endDate"
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets