Skip to content

Conversation

mia-krause
Copy link
Contributor

Solves #271

Signed-off-by: Mia <mia.krause004@stud.fh-dortmund.de>
@codecov
Copy link

codecov bot commented Feb 3, 2021

Codecov Report

Merging #272 (e59e93c) into dev (45235fe) will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev     #272      +/-   ##
============================================
+ Coverage     78.24%   78.25%   +0.01%     
- Complexity     1943     1947       +4     
============================================
  Files           247      247              
  Lines          7900     7910      +10     
  Branches        747      747              
============================================
+ Hits           6181     6190       +9     
  Misses         1301     1301              
- Partials        418      419       +1     
Impacted Files Coverage Δ Complexity Δ
...odel/io/source/influxdb/InfluxDbWeatherSource.java 87.77% <0.00%> (-0.86%) 21.00% <0.00%> (+1.00%) ⬇️
.../edu/ie3/datamodel/io/connectors/SqlConnector.java 68.75% <0.00%> (+6.25%) 12.00% <0.00%> (+4.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 45235fe...e59e93c. Read the comment docs.

@ckittl
Copy link
Member

ckittl commented Feb 4, 2021

!test

.map(weatherValueFactory::get);
}

private String createQueryStringForIntervalAndCoordinate(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private String createQueryStringForIntervalAndCoordinate(
private String createQueryStringForCoordinateAndTimeInterval(

+ createTimeConstraint(timeInterval);
}

private String createQueryStringForDateAndCoordinate(ZonedDateTime date, int coordinateId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private String createQueryStringForDateAndCoordinate(ZonedDateTime date, int coordinateId) {
private String createQueryStringForCoordinateAndTime(ZonedDateTime date, int coordinateId) {

ClosedInterval<ZonedDateTime> timeInterval, int coordinateId) {
return createQueryStringForInterval(timeInterval)
return BASIC_QUERY_STRING
+ " where "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might consider introducing a constant for " where ". It's not too vital, but reduces the number of code smells...

return coordinateToTimeSeries;
}

private Connection getConnection() throws SQLException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my POV we should discuss, if holding a connection should better be moved to the connector itself. Either SqlConnector having an attribute reuseConnection or the getter being like

public getConnection() throws SQLException {
  return getConnection(false);
}

public getConnection(boolean reuseConnection) throws SQLException {
  if (reuseConnection && (connection == null || connection.isClosed()) || !reuseConnection) connection = connector.getConnection();
    return connection;
}

What are your thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good point. Especially bc otherwise it would be impossible to execute concurrent db calls with the same weather source (we would have to create a new weather source for each concurrent call). However, I would prefer having a slightly more elaborated approach, where the number of parallel connections is tracked in order to not create too much concurrent connections. This might be possible with a list or map holding the actual open connections and either returns one of them that is currently not used or creates a new one. Furthermore, in this case the connector should keep "its space clean" by automatically remove unused connections whenever a new getConnection call is executed.

Maybe we can discuss this in a short call?

Copy link
Member

@ckittl ckittl Feb 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boy, that escalated quickly. 😃

I'm open to a call. But then we might consider splitting up the PR into on InfluxDB- and one SQL-PR?!

@johanneshiry
Copy link
Member

!test

@johanneshiry johanneshiry added the bug Something isn't working label Feb 19, 2021
@johanneshiry johanneshiry added this to the Version 2.0 milestone Feb 19, 2021
ckittl
ckittl previously approved these changes Feb 25, 2021
@ckittl ckittl merged commit fbfeb04 into dev Feb 25, 2021
@ckittl ckittl deleted the mk/#271-minor-database-issues branch February 25, 2021 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants