-
Notifications
You must be signed in to change notification settings - Fork 5
Deduplicate Activate #53
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
Open
ABTastyAdel
wants to merge
8
commits into
5.0.0-beta
Choose a base branch
from
deduplicateActivate
base: 5.0.0-beta
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a477a84
add dediplicate
ABTastyAdel 4d66c5f
add unit tests
ABTastyAdel f1c9d6c
clean code
ABTastyAdel f859784
clean code
ABTastyAdel 64618c8
fix review
ABTastyAdel 21f7231
update version
ABTastyAdel 1fd8420
secure code
ABTastyAdel bd46dec
update verison
ABTastyAdel 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,11 +8,15 @@ | |
|
|
||
| import Foundation | ||
|
|
||
| let FS_SESSION_VISITOR: TimeInterval = 30.0 // 30 * 60 /// 30 mn | ||
ABTastyAdel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public extension FSVisitor { | ||
| /// Get FSFlag object | ||
| /// - Parameter key: key represent key modification | ||
| /// - Returns: FSFLag object | ||
| func getFlag(key: String) -> FSFlag { | ||
| /// Init the session | ||
| self.sessionStartDate = Date() | ||
| // We dispaly a warning if the flag's status is not fetched | ||
| if self.fetchStatus != .FETCHED { | ||
| FlagshipLogManager.Log(level: .ALL, tag: .FLAG, messageToDisplay: FSLogMessage.MESSAGE(self.requiredFetchReason.warningMessage(key, self.visitorId))) | ||
|
|
@@ -23,13 +27,53 @@ public extension FSVisitor { | |
| /// Getting FSFlagCollection | ||
| /// - Returns: an instance of FSFlagCollection with flags | ||
| func getFlags() -> FSFlagCollection { | ||
| /// Init the session | ||
| self.sessionStartDate = Date() | ||
| var ret: [String: FSFlag] = [:] | ||
| self.currentFlags.forEach { (key: String, _: FSModification) in | ||
|
|
||
| ret.updateValue(FSFlag(key, self.strategy), forKey: key) | ||
| } | ||
| return FSFlagCollection(flags: ret) | ||
| } | ||
|
|
||
| internal func isDeduplicatedFlag(campId: String, varGrpId: String) -> Bool { | ||
| var ret = true | ||
| let duration = Date().timeIntervalSince(self.sessionStartDate) | ||
|
|
||
| print("the timeinterval duration is \(round(duration))") | ||
|
|
||
| if round(duration) > FS_SESSION_VISITOR { | ||
| print("La session a duré plus de 30 minutes ----------") | ||
| print("vider les saves et envoyer les activates quant meeme") | ||
|
|
||
| // Clear all saved ids for flags | ||
| self.activatedVariations.removeAll() | ||
|
|
||
| /// Register et ordonner l envoie | ||
|
||
| self.activatedVariations.merge([campId: varGrpId]) { _, new in new } | ||
|
|
||
| ret = false | ||
| } else { | ||
| print("la session a moins que 30 minutes ===> alors on check avant d envoyer activate") | ||
|
|
||
| if self.activatedVariations.keys.contains(campId) { | ||
| if varGrpId == self.activatedVariations[campId] { | ||
| /// The activation is already done | ||
| print("========== Already activated ============") | ||
| ret = true | ||
| } | ||
| } else { | ||
| /// Register et ordonner l envoie | ||
| self.activatedVariations.merge([campId: varGrpId]) { _, new in new } | ||
| print("========== GO for activation ============") | ||
| ret = false | ||
| } | ||
| } | ||
| /// reset the timestamps | ||
| self.sessionStartDate = Date() | ||
| return ret | ||
| } | ||
| } | ||
|
|
||
| // We keep FlagMap instead using FSFlagV4 wich is also possible | ||
|
|
||
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
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.