Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

improve: Export form id and version to fix #236 #239

Merged
merged 4 commits into from
Dec 8, 2020

Conversation

florianm
Copy link
Contributor

@florianm florianm commented Dec 2, 2020

This PR closes #236

  • Timestamped form slug becomes now form version
  • Sanitized form title component of form slug becomes form id
  • Updated deps in Gemfile - needed to do so to resolve a build error
  • Tested locally with
    • "Untitled Form" becomes <data id="Untitled-Form" version="build_Untitled-Form_1606880517">
    • <h:title>Test 123!@# 123#$%5</h:title> becomes <data id="Test-123-123-5" version="build_Test-123-123-5_1606880579">
  • Ran tests, but something went wrong:
rake test
WARNING: using development env because no RACK_ENV was supplied.
/var/lib/gems/2.7.0/gems/sinatra-1.2.6/lib/sinatra/base.rb:1238: warning: assigned but unused variable - e
/var/lib/gems/2.7.0/gems/sinatra-1.2.6/lib/sinatra/base.rb:1363: warning: mismatched indentations at 'end' with 'else' at 1361
/var/lib/gems/2.7.0/gems/sinatra-1.2.6/lib/sinatra/base.rb:1308: warning: method redefined; discarding old run
/var/lib/gems/2.7.0/gems/sinatra-1.2.6/lib/sinatra/base.rb:1454: warning: previous definition of run was here
/var/lib/gems/2.7.0/gems/sinatra-1.2.6/lib/sinatra/base.rb:1308: warning: method redefined; discarding old run?
/var/lib/gems/2.7.0/gems/sinatra-1.2.6/lib/sinatra/base.rb:947: warning: previous definition of run? was here
/var/lib/gems/2.7.0/gems/sinatra-1.2.6/lib/sinatra/base.rb:1308: warning: method redefined; discarding old run=
/var/lib/gems/2.7.0/gems/sinatra-1.2.6/lib/sinatra/base.rb:948: warning: previous definition of run= was here
/var/lib/gems/2.7.0/gems/warden-1.0.6/lib/warden/proxy.rb:68: warning: assigned but unused variable - opts
/var/lib/gems/2.7.0/gems/warden-1.0.6/lib/warden/proxy.rb:90: warning: assigned but unused variable - opts
/var/lib/gems/2.7.0/gems/warden-1.0.6/lib/warden/manager.rb:22: warning: `*' interpreted as argument prefix

File does not exist: warden_odkbuild

0 passes, 0 failures, 0 errors in 0.000001 seconds

This change is Reviewable

* Timestamped form slug becomes now form version
* Sanitized form title component of form slug becomes form id
* Updated deps in Gemfile
@florianm
Copy link
Contributor Author

florianm commented Dec 2, 2020

Aha, CircleCI is not happy with my newer Ruby version.

Using the version pinned in CircleCI (2.3.3):

rbenv install 2.3.3
Downloading ruby-2.3.3.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.bz2
Installing ruby-2.3.3...

WARNING: ruby-2.3.3 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

Seeing there's almost no test coverage to pick up any regression bugs (not judging!), it feels rude to sneak a Ruby version upgrade into this PR, so I'll try and keep versions as is. Reverting my commit to the Gemfile and pushing shortly.

@florianm
Copy link
Contributor Author

florianm commented Dec 2, 2020

I'm happy to submit this PR for review now.

The big question is: which use cases break if the form ID follows the form title.

@@ -346,7 +346,7 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');

// create binding based on kind
var kind = control.kind.toLowerCase();
if (kind == 'device id')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, that's me editor deleting trailing whitespace on file save. Hope that's OK to submit.

Copy link
Member

Choose a reason for hiding this comment

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

if this were an active project i'd grouse but as is it's totally fine.

@@ -706,8 +706,7 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');
name: 'data',
attrs: {
'id': $.sanitizeString($('.header h1').text()),
'version': 'build_' + $.sanitizeString($('.header h1').text()) +
'_' + Math.round((new Date()).getTime() / 1000)
'version': Math.round((new Date()).getTime() / 1000)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressing #236 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Version needs to be '' + Math.round to become a string else XML export fails when it gets the date hash as number.

Copy link
Member

Choose a reason for hiding this comment

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

i might mildly prefer String(Math.round(…)) over '' + but tbh the latter is probably the more common pattern anyway.

@florianm
Copy link
Contributor Author

florianm commented Dec 3, 2020

@lognaturel I'm happy to submit this two-line PR for review now, XML exports form id (sanitized title) and version (string of date hash). XLSForm export will need getodk/build2xlsform#14 to adjust behaviour.

florianm pushed a commit to florianm/build2xlsform that referenced this pull request Dec 3, 2020
* Sanitized form title becomes form_id
* user_version or date hash becomes version
* version now always included
* tests updated
* This behaviour mirrors getodk/build#239
@issa-tseng issa-tseng merged commit 6d28f17 into getodk:master Dec 8, 2020
@florianm florianm deleted the 236-form-id-and-version branch December 8, 2020 04:16
florianm pushed a commit to dbca-wa/build that referenced this pull request Dec 8, 2020
florianm pushed a commit to dbca-wa/build that referenced this pull request Dec 8, 2021
Resolves getodk#239 (comment)
Mild preferences are still preferences
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exported XML should keep form id static and increase version
2 participants