-
-
Notifications
You must be signed in to change notification settings - Fork 45
CCCT-2016 Create Release Toggles DB Table #3482
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
Merged
conroy-ricketts
merged 17 commits into
master
from
task/CCCT-2016-release-toggles-database-table
Jan 13, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7d9f219
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts c92e91b
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts 51ff96d
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts 7630ca1
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts 5d4ce63
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts cb2f760
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts ef3c88a
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts f574ed3
Merge branch 'master' of https://github.com/dimagi/commcare-android i…
conroy-ricketts b6ca56b
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts a3653eb
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts e2552cb
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts cd29799
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts 798ca84
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts f8f927c
Merge branch 'master' of https://github.com/dimagi/commcare-android i…
conroy-ricketts da7c1e5
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts 4fc8dae
CCCT-2016 Create Release Toggles DB Table
conroy-ricketts 5e4f747
Merge branch 'master' of https://github.com/dimagi/commcare-android i…
conroy-ricketts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
app/src/org/commcare/android/database/connect/models/ConnectReleaseToggleRecord.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| package org.commcare.android.database.connect.models | ||
|
|
||
| import org.commcare.android.storage.framework.Persisted | ||
| import org.commcare.models.framework.Persisting | ||
| import org.commcare.modern.database.Table | ||
| import org.commcare.modern.models.MetaField | ||
| import org.javarosa.core.model.utils.DateUtils | ||
| import org.javarosa.core.services.Logger | ||
| import org.json.JSONException | ||
| import org.json.JSONObject | ||
| import java.io.Serializable | ||
| import java.util.Date | ||
|
|
||
| @Table(ConnectReleaseToggleRecord.STORAGE_KEY) | ||
| class ConnectReleaseToggleRecord : | ||
| Persisted(), | ||
| Serializable { | ||
| @Persisting(1) | ||
| @MetaField(META_SLUG) | ||
| var slug: String | ||
| private set | ||
|
|
||
| @Persisting(2) | ||
| @MetaField(META_ACTIVE) | ||
| var active: Boolean | ||
| private set | ||
|
|
||
| @Persisting(3) | ||
| @MetaField(META_CREATED_AT) | ||
| var createdAt: Date | ||
| private set | ||
|
|
||
| @Persisting(4) | ||
| @MetaField(META_MODIFIED_AT) | ||
| var modifiedAt: Date | ||
| private set | ||
|
|
||
| init { | ||
| slug = "" | ||
| active = false | ||
| createdAt = Date() | ||
| modifiedAt = Date() | ||
| } | ||
|
|
||
| companion object { | ||
| // Name of database that stores connect release toggles. | ||
| const val STORAGE_KEY = "connect_release_toggles" | ||
|
|
||
| const val META_SLUG = "slug" | ||
| const val META_ACTIVE = "active" | ||
| const val META_CREATED_AT = "created_at" | ||
| const val META_MODIFIED_AT = "modified_at" | ||
|
|
||
| fun releaseTogglesFromJson(json: JSONObject): List<ConnectReleaseToggleRecord> { | ||
| val releaseToggles = mutableListOf<ConnectReleaseToggleRecord>() | ||
| val slugKeys = json.keys() | ||
|
|
||
| while (slugKeys.hasNext()) { | ||
| val slugKey = slugKeys.next() | ||
|
|
||
| try { | ||
| val releaseToggleJson = json.getJSONObject(slugKey) | ||
| releaseToggles.add(releaseToggleFromJson(slugKey, releaseToggleJson)) | ||
| } catch (e: JSONException) { | ||
| Logger.exception("JSONException while retrieving a release toggle", e) | ||
| } | ||
| } | ||
|
|
||
| return releaseToggles | ||
| } | ||
|
|
||
| @Throws(JSONException::class) | ||
| fun releaseToggleFromJson( | ||
| slugKey: String, | ||
| json: JSONObject, | ||
| ): ConnectReleaseToggleRecord = | ||
| ConnectReleaseToggleRecord().apply { | ||
| val createdAtDateString = json.getString(META_CREATED_AT) | ||
| val modifiedAtDateString = json.getString(META_MODIFIED_AT) | ||
|
|
||
| slug = slugKey | ||
| active = json.getBoolean(META_ACTIVE) | ||
| createdAt = DateUtils.parseDateTime(createdAtDateString) | ||
| modifiedAt = DateUtils.parseDateTime(modifiedAtDateString) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.