shm-open / code-push-server

CodePush service is an app hot update service which is compatible with react-native-code-push and other CodePush clients
MIT License
191 stars 53 forks source link

Use latest matching deployment #162

Closed byronigoe closed 2 years ago

byronigoe commented 2 years ago

Download the most recently uploaded package that matches the version instead of always choosing the most specific deployment

rocwind commented 2 years ago

@byronigoe Thanks for the PR! it seems reasonable to choose the latest but not more specific version. We have not used the MS official service before so I am not sure about the behavior of official service, but I checked the code-push-cli doc and didn't find any information about more specific target version should be prefered to version range. As regards the changes here, I'll need to double check the rollback & prompt cases, not sure about whether sorting by created_at works for them.

rocwind commented 2 years ago

@byronigoe It looks like it always create new packages for rollback & prompt cases, I guess use created_at is fine. Would you mind helping with the lint issue? I'll merge this PR once it passes CI.

btw: since we only need the last array item, maybe _.last(_.sort(...)) can be faster that .reverse()[0]. It might be even better to sort and findOne with sql query, but I suppose current solution is good enough for addressing the issue itself.