Giter Club home page Giter Club logo

central-backend's Introduction

opendatakit

The developer wiki (including release notes) and issues tracker are located here.

This site is primarily for developers. If you are not a developer, please visit https://getodk.org/

ODK is a free and open-source set tools which help organizations author, field, and manage mobile data collection solutions. ODK provides an out-of-the-box solution for users to:

  • Build a data collection form or survey;
  • Collect the data on a mobile device and send it to a server; and
  • Aggregate the collected data on a server and extract it in useful formats.

In addition to socio-economic and health surveys with GPS locations and images, ODK is being used to create decision support for clinicians and for building multimedia-rich nature mapping tools. See featured deployments and list of tools for more examples of what the ODK community is doing. We welcome and encourage participation from the user community.

Downloads of the tools are available at Downloads.

central-backend's People

Contributors

akshay-ap avatar alxndrsn avatar danbjoseph avatar dependabot[bot] avatar ggalmazor avatar issa-tseng avatar jnm avatar josephvoid avatar ktuite avatar lognaturel avatar matthew-white avatar nizamlz avatar sadiqkhoja avatar spwoodcock avatar yanokwa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

central-backend's Issues

Choose an inline-documentation system

The answer might be "Other: inline-documentation sucks, do this instead."

But especially since JS is dynamically typed, there needs to be an easy API function signature reference of some kind.

Tune linter

Clint writes:

Tune the linter according to the notes I had on the Airbnb lint profile, and resolve any outstanding issues that then remain.

Add integration tests for database

From our call today, it sounds like we want to add integration tests in addition to unit tests for the database. This issue is to add those integration tests: #10 encompasses only unit tests.

As part of this, I think we should create a test database?

Error handling backstop / don't send stack traces

Right now, in some cases, if a request causes the server to throw an error, the stack trace is sent back as the response. How about we add error handling such that such cases result in a 500 response as JSON rather than a stack trace? I think that even if the JavaScript has a syntax error, tries to reassign a const, etc., that shouldn't result in a stack trace sent to the end user.

Replace fast-xml-parser

There are some fundamental issues with it:

  1. It does not accept streams as input.
  2. It swallows text nodes when they are siblings to child nodes.
  3. It presents attributes differently (in a way our code currently does not handle well) when there are vs aren't child nodes.

Container state is leaking for some reason

If container is created at top-level scope in test/api/setup.js (eg the injector initialization inside testService is moved above that block), it is the first-created container. Then, the initialized services accidentally use the container generate to run the fixture scripts (which is created last) instead of the container we explicitly pass in in testService. This should not be happening. I suspect it may have something to do with Ramda curry doing unexpected nasty things, but I have bigger fish to fry at the moment.

Testing scheme for database calls

Clint writes:

  • Devise a testing scheme for … database calls that elude straightforward unit testing.
  • Unit test more/all of the surface area we have imported already.

You could also split this into two issues if that's easier…

CircleCI can't connect to Postgres

When running tests:

node -e 'const { withDatabase, migrate } = require("./lib/model/database"); withDatabase(migrate);'
Unhandled rejection Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object._errnoException (util.js:1026:11)
    at _exceptionWithHostPort (util.js:1049:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)

I think postgres just isn't started.

Add license

This should be Apache License 2.0, right?

Update behavior of merge()

My vote would be to have merge() in util.js match the behavior of Object.assign() and spread syntax: I think any differences could be confusing. Right now, merge() automatically concatenates values that are arrays (rather than replacing them) and will not replace a value with null or undefined. In most cases, I think we'd want merge() to fully replace values. An implementation could maybe we as simple as:

const merge = (...objs) => Object.assign({}, ...objs);

Alternatively, perhaps we could have merge take an options parameter...

Thoughts?

`npm install` failure on Ubuntu

Hi! I've cloned the repo and tried an npm install but it has failed.

  • node -v tells v9.3.0
  • npm -version tells 5.6.0

This is the output:

> [email protected] install /home/guillermo/src/nafundi/jubilant-garbanzo/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v59-linux-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v59 ABI) (falling back to source compile with node-gyp) 
make: se entra en el directorio '/home/guillermo/src/nafundi/jubilant-garbanzo/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
../src/bcrypt.cc: In function ‘void encode_salt(char*, u_int8_t*, u_int16_t, u_int8_t)’:
../src/bcrypt.cc:132:1: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
 encode_salt(char *salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr)
 ^~~~~~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from ../src/bcrypt.cc:48:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:65:44: note: ‘__builtin___snprintf_chk’ output between 4 and 5 bytes into a destination of size 4
        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
../src/bcrypt.cc: In function ‘void bcrypt(const char*, const char*, char*)’:
../src/bcrypt.cc:165:1: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
 bcrypt(const char *key, const char *salt, char *encrypted)
 ^~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from ../src/bcrypt.cc:48:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:65:44: note: ‘__builtin___snprintf_chk’ output between 4 and 5 bytes into a destination of size 4
        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
In file included from ../../nan/nan.h:192:0,
                 from ../src/bcrypt_node.cc:1:
../../nan/nan_maybe_43_inl.h: In function ‘Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’:
../../nan/nan_maybe_43_inl.h:112:73: warning: ‘v8::Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’ is deprecated: Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
                                                                         ^
In file included from /home/guillermo/.node-gyp/9.3.0/include/node/v8.h:26:0,
                 from /home/guillermo/.node-gyp/9.3.0/include/node/node.h:63,
                 from ../../nan/nan.h:49,
                 from ../src/bcrypt_node.cc:1:
/home/guillermo/.node-gyp/9.3.0/include/node/v8.h:3115:29: note: declared here
                 Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
                             ^
/home/guillermo/.node-gyp/9.3.0/include/node/v8config.h:318:3: note: in definition of macro ‘V8_DEPRECATED’
   declarator __attribute__((deprecated(message)))
   ^~~~~~~~~~
  SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
  COPY Release/bcrypt_lib.node
  COPY /home/guillermo/src/nafundi/jubilant-garbanzo/node_modules/bcrypt/lib/binding/bcrypt_lib.node
  TOUCH Release/obj.target/action_after_build.stamp
make: se sale del directorio '/home/guillermo/src/nafundi/jubilant-garbanzo/node_modules/bcrypt/build'
added 522 packages in 5.922s

CLI: user-create error

I think we've seen this before, so this may be on @clint-tseng's radar already, but FYI, I'm seeing an error when I run node lib/cli.js user-create:

$ node lib/cli.js -u [email protected] -p password user-create
Required parameter displayName missing.
{ field: 'displayName' }

It was an easy fix, and this isn't blocking anything, but I just wanted to make sure we had an issue filed.

Base.prototype.update() always resolves with false

This may be on @clint-tseng's radar already, but right now, I think Base.prototype.update() always resolves the promise with false. db.update() seems to resolve the promise with the number of affected rows, not an object with a rowCount property. For example:

> const { connect } = require('./lib/model/database');
> const db = connect();
> db.
    update({ xmlFormId: 'newFormId' }).
    into('forms').
    where({ id: 1 }).
    then(result => console.log(result));
1 // Not { rowCount: 1 }

Since Base.prototype.update() looks for a rowCount property but will never find one, I think the promise will always resolve with false.

Test result structure assertions need improvement

Right now we do weird dirty tricks like mapping the objects through functions that assert a property then eliminate that property, so that in the end we can do an eql({ … }) check against the stable data that remains.

For one, these functions get awkward applied to non-lists.
For two, the implicit data munging (even though it is immutable transformation) is troublesome.
For three, it is highly repetitive.

Vue.js browser compatibility

@clint-tseng and I are thinking of starting out with Vue.js. It supports "all browsers that are ES5-compliant (IE8 and below are not supported)" (see here). I think that should be fine, especially since Jubilant will be the server component, but we wanted to double-check that that'd work alright…

Have submissions .csv output match Briefcase

When Jubilant outputs multiple .csv files, how closely should their format match Briefcase? I tend to think that they should match as closely as possible so that extensions and workflows based on the Briefcase output will continue to work with Jubilant. How much work would that entail?

Add high-level narrative

I didn't see an existing issue/PR for this, so I just wanted to add a +1 to @lognaturel's comment in #32:

The commit comments are really helpful and I would like to see a little bit of that become comments and/or dev docs. I know that @cxlt you were reluctant to get started with dev docs because understandably you expect things will change but I think just a little bit of high-level narrative now would help. A concrete way to start would be to take Instance.with(ActeeTrait)(({ Grant, actors, all, grants, simply }) => class and upack it a little bit. Link out to a good narrative on traits, describe that package.js is the dependency injection container, a paragraph on Option, things like that. I think a few minutes on that would help a lot with giving someone an idea of where to start. It doesn't have to go in this PR.

Responses from /forms with extended metadata

I'm noticing a couple of null fields in responses from /forms when I request extended metadata:

  • formId. I see that forApi() in instance/form.js excludes the id field. I think the null value is coming from submission_stats.formId.
  • submissions. This seems to be null rather than zero when there are no submissions. I could see a case being made for either one, but I'd lean toward returning zero.

This isn't blocking anything on the Adventure side, but I thought I'd mention it as a possible future to-do.

Soft-deleted user accounts should allow duplicate emails

We are soft-deleting accounts and formdata, so that recovery is possible. But this means that if an account is deleted, a new one cannot be created at the same address, as the unique constraint still applies.

The likely solution is to bind the unique constraint on a compound (email, deletedAt). But because account deletion isn't actually in the initial release, we can punt.

Test assertions can't rely on object ids

Because autoincrement sequences do not rollback with a transaction, and therefore generated ids are dependent on test order and inclusion. So the best we can do is assert a number.

Right now, there are many tests that assert a specific number, which is dependent on the other tests involving that model running in a particular order and inclusion. The whole suite works stably, so this isn't catastrophically urgent, but should be addressed, probably at the same time as #55.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.