Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closes #53 - add influxDB #244

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Ulisseus
Copy link
Contributor

@Ulisseus Ulisseus commented Oct 28, 2020

InfluxDB was chosen over TimescaleDB mostly because latter requires older versions of Postgres and maintaining multiply psqls on the same machine is rather annoying. It's also more popular at least for now.

Since this PR adds new influxDB button welcome page snapshots were updated.

To safely merge:

  • InfluxDB 1.8 needs to be installed
  • INF_HOST and INF_PORT environment variables should be configured, by default it's localhost and 8086
  • src/routes/renderRoutes.js line 22 Influx: "PRODUCTION INFLUXDB HOST", needs to be changed to whatever host will be used in production

Proofreading of influxDB tutorial is appreciated.

@codecov
Copy link

codecov bot commented Oct 28, 2020

Codecov Report

Merging #244 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #244   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        14    +1     
  Lines          494       540   +46     
  Branches        55        63    +8     
=========================================
+ Hits           494       540   +46     
Impacted Files Coverage Δ
database/influx/influx.js 100.00% <100.00%> (ø)
lib/util.js 100.00% <100.00%> (ø)
src/routes/renderRoutes.js 100.00% <100.00%> (ø)
src/routes/userRoutes.js 100.00% <100.00%> (ø)
src/server.js 100.00% <100.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 ab9e22d...398b0de. Read the comment docs.

throw new Error(`failed to create new influx user with ${username} name`);
}
};
influxModule.deleteAccount = async (account) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function only uses username, so why is the entire account object needed?

lib/util.js Outdated
@@ -37,6 +38,9 @@ util.cleanAnonymous = async () => {
const arangoDbExists = await arango.checkIfDatabaseExists(username);
if (arangoDbExists) await arango.deleteAccount(username);

const influxDbExists = await influx.checkAccount(username);
if (influxDbExists) await influx.deleteAccount(user);
Copy link
Collaborator

@anthonykhoa anthonykhoa Oct 28, 2020

Choose a reason for hiding this comment

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

You have the choice to pass in username, so you should do that instead of user. I don't think it makes sense to pass in an object to a function that only uses one string data-type variable as an input. That is confusing -- it makes me think that the function needs something else from user other than just user.username

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically, this code threw me off. PG and Elastic use username for checks and user for deletions while Arango needs only username in both cases. I was trying to be consistent so I added user as argument for Influx.

    const pgDbExists = await pg.userHasPgAccount(username);
    if (pgDbExists) await pg.deletePgAccount(user);

    const esDbExists = await es.checkAccount(username);
    if (esDbExists) await es.deleteAccount(user);

    const arangoDbExists = await arango.checkIfDatabaseExists(username);
    if (arangoDbExists) await arango.deleteAccount(username);

I changed it, so deleteAccount now needs only username as argument.

src/server.js Outdated
@@ -19,6 +19,7 @@ let server = null;
let app = null;

const arangoModule = require("../database/arango/arango");
const influxModule = require("../database/influx/influx.js");
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need the .js when importing a JS file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants