-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: achievement system documentation #944
base: master
Are you sure you want to change the base?
Conversation
* add first draft of tables * first minor changes * add draft: aggregator, formula, bucket, metric * remove isAchieved * adjusted schema for achievements * add actionTaken() * comment: example import * add relation adjust formula return value * specific context * add migration * add metric and generic formula context * check for achievement action * fix integration * adjust prop for bucket formula * add cached achievement template * register metrics * add map for metric by name and by action
* add first draft of tables * first minor changes * add draft: aggregator, formula, bucket, metric * remove isAchieved * adjusted schema for achievements * add actionTaken() * comment: example import * add function to track events * add relation adjust formula return value * specific context * add migration * add metric and generic formula context * check for achievement action * track context * fix integration * adjust prop for bucket formula * add cached achievement template * register metrics * remove comment * add map for metric by name and by action * adjust for metrics map
first draft
* add first draft of tables * first minor changes * add draft: aggregator, formula, bucket, metric * remove isAchieved * adjusted schema for achievements * add actionTaken() * comment: example import * add function to track events * add relation adjust formula return value * specific context * add migration * add metric and generic formula context * check for achievement action * track context * fix integration * adjust prop for bucket formula * add cached achievement template * register metrics * remove comment * add map for metric by name and by action * adjust for metrics map * add first bucket creators * add package swan * add relation resolution * add first draft to evaluate * add function to check for achievements * add achievements by group * add create user achievement * adjusted evaluation * some drafts * adjust create sequential user achievement * add feature flag * add test actions and mutations * add achieved image to db * adjust next step index * fix awarding user * seed db example type swan js parser * feat: evaluation of tiered achievements (#910) feat: filter bucket with achievement creation * feat: evaluation of streaks (#909) * feat: filter bucket with achievement creation * fix: branch update * fix: create time buckets returning buckets * feat: streak evaluation * fix: update streak with correct values * fix: merge clearing * fix inject record value * fix: make it work * fix: work in change requests * fix: safe empty json in db * fix: requested changes * fix: add condition for relation Co-authored-by: LomyW <[email protected]> * fix: remove test data, change requests * feat: refactor of aggregators (#926) * refactor of aggregators * review changes * rename streak aggregator --------- Co-authored-by: LucasFalkowsky <[email protected]> Co-authored-by: Lucas <[email protected]>
* add first draft of tables * first minor changes * add draft: aggregator, formula, bucket, metric * remove isAchieved * adjusted schema for achievements * add actionTaken() * comment: example import * add function to track events * add relation adjust formula return value * specific context * add migration * add metric and generic formula context * check for achievement action * track context * fix integration * adjust prop for bucket formula * add cached achievement template * register metrics * remove comment * add map for metric by name and by action * adjust for metrics map * add first bucket creators * add package swan * add relation resolution * add first draft to evaluate * add function to check for achievements * add achievements by group * add create user achievement * feat: backend implementation achievement resolver * adjusted evaluation * some drafts * adjust create sequential user achievement * add feature flag * add test actions and mutations * add achieved image to db * adjust next step index * fix: change requests * fix awarding user * seed db example type swan js parser * feat: evaluation of tiered achievements (#910) feat: filter bucket with achievement creation * feat: evaluation of streaks (#909) * feat: filter bucket with achievement creation * fix: branch update * fix: create time buckets returning buckets * feat: streak evaluation * fix: update streak with correct values * fix: merge clearing * fix: removed unnecessary checks and added comments * fix inject record value * fix: make it work * fix: change index generation for state handling * fix: work in change requests * fix: add values to context * fix: safe empty json in db * fix: set right achievement state * fix: change requests * fix: requested changes * fix: add condition for relation Co-authored-by: LomyW <[email protected]> * fix: remove test data, change requests * fix: reset achievedAt when condition not met * feat: refactor of aggregators (#926) * refactor of aggregators * review changes * rename streak aggregator * feat: relation context (#911) * feat: save and get by relation match and subcourse * fix: remove empty context * fix: added sampleContext and adjustet mutations * fix: update AchievementContext * fix: adjustment of Achievement Context * fix: introduce helper functions, refactor context * fix: type duplication * fix: reflect metadata --------- Co-authored-by: LomyW <[email protected]> Co-authored-by: LomyW <[email protected]> * feat: achievement is seen (#925) * feat: mutation for seen achievements * fix: change requests * fix: no await to get user achievements Co-authored-by: Daniel Henkel <[email protected]> * feat: resolver values (#928) * feat: save and get by relation match and subcourse * add templates to seed db * fix: get next template on index * add metric and actions for student onboarding * trigger onboarding actions * - add pupil onboarding, conducted match meetings - student conducted match meetings * fix: create achievement next step index * add metrics and action for pupil onboarding * add achievement mutation resolver * extend meeting action context * add data for regular learned streak * fix: remove empty context * fix: added sampleContext and adjustet mutations * fix: update AchievementContext * fix: adjustment of Achievement Context * fix bucket by lecture start * prevent more events for one bucket * fix relation for buckets * fix bucket * get user achievement for create next * fix: introduce helper functions, refactor context * adjust bucketCreator for regular learned to weekly * fix: type duplication * fix: reflect metadata * fix: reflect metadata * refactor of aggregators * review changes * rename streak aggregator * adjust streak data * sort desc * feat: evaluation in resolver * fix: add record value to evaluation * fix: await achievements in resolver * fix: change requests --------- Co-authored-by: LomyW <[email protected]> Co-authored-by: LomyW <[email protected]> * fix: changes requested * move recordValue to evaluate (#929) * fix: break and change description to name --------- Co-authored-by: LomyW <[email protected]> Co-authored-by: LomyW <[email protected]> Co-authored-by: Daniel Henkel <[email protected]>
* add first draft of tables * first minor changes * add draft: aggregator, formula, bucket, metric * remove isAchieved * adjusted schema for achievements * add actionTaken() * comment: example import * add function to track events * add relation adjust formula return value * specific context * add migration * add metric and generic formula context * check for achievement action * track context * fix integration * adjust prop for bucket formula * add cached achievement template * register metrics * remove comment * add map for metric by name and by action * adjust for metrics map * add first bucket creators * add package swan * add relation resolution * add first draft to evaluate * add function to check for achievements * add achievements by group * add create user achievement * adjusted evaluation * some drafts * adjust create sequential user achievement * add feature flag * add test actions and mutations * add achieved image to db * adjust next step index * fix awarding user * seed db example type swan js parser * feat: evaluation of tiered achievements (#910) feat: filter bucket with achievement creation * feat: evaluation of streaks (#909) * feat: filter bucket with achievement creation * fix: branch update * fix: create time buckets returning buckets * feat: streak evaluation * fix: update streak with correct values * fix: merge clearing * fix inject record value * fix: make it work * fix: work in change requests * fix: safe empty json in db * fix: requested changes * feat: achievement event notification trigger * fix: remove achievement seen * fix: add condition for relation Co-authored-by: LomyW <[email protected]> * fix: remove test data, change requests * fix: change requests * fix: add name and id to context for actionTakenAt * fix: merge conflicts * fix: add missing actions * fix: spelling mistaek --------- Co-authored-by: LomyW <[email protected]> Co-authored-by: LomyW <[email protected]>
* add first draft of tables * first minor changes * add draft: aggregator, formula, bucket, metric * remove isAchieved * adjusted schema for achievements * add actionTaken() * comment: example import * add function to track events * add relation adjust formula return value * specific context * add migration * add metric and generic formula context * check for achievement action * track context * fix integration * adjust prop for bucket formula * add cached achievement template * register metrics * remove comment * add map for metric by name and by action * adjust for metrics map * add first bucket creators * add package swan * add relation resolution * add first draft to evaluate * add function to check for achievements * add achievements by group * add create user achievement * feat: backend implementation achievement resolver * adjusted evaluation * some drafts * adjust create sequential user achievement * add feature flag * add test actions and mutations * add achieved image to db * adjust next step index * fix: change requests * fix awarding user * seed db example type swan js parser * feat: evaluation of tiered achievements (#910) feat: filter bucket with achievement creation * feat: evaluation of streaks (#909) * feat: filter bucket with achievement creation * fix: branch update * fix: create time buckets returning buckets * feat: streak evaluation * fix: update streak with correct values * fix: merge clearing * fix: removed unnecessary checks and added comments * fix inject record value * fix: make it work * fix: change index generation for state handling * fix: work in change requests * feat: save and get by relation match and subcourse * add templates to seed db * fix: get next template on index * add metric and actions for student onboarding * trigger onboarding actions * fix: add values to context * fix: safe empty json in db * fix: set right achievement state * - add pupil onboarding, conducted match meetings - student conducted match meetings * fix: create achievement next step index * add metrics and action for pupil onboarding * add achievement mutation resolver * extend meeting action context * add data for regular learned streak * fix: change requests * fix: remove empty context * fix: added sampleContext and adjustet mutations * fix: requested changes * fix: update AchievementContext * fix: adjustment of Achievement Context * fix bucket by lecture start * prevent more events for one bucket * fix relation for buckets * fix bucket * get user achievement for create next * fix: introduce helper functions, refactor context * adjust bucketCreator for regular learned to weekly * fix: add condition for relation Co-authored-by: LomyW <[email protected]> * fix: remove test data, change requests * fix: reset achievedAt when condition not met * fix: type duplication * fix: reflect metadata * fix: reflect metadata * refactor of aggregators * review changes * rename streak aggregator * adjust streak data * sort desc * feat: refactor of aggregators (#926) * refactor of aggregators * review changes * rename streak aggregator * feat: relation context (#911) * feat: save and get by relation match and subcourse * fix: remove empty context * fix: added sampleContext and adjustet mutations * fix: update AchievementContext * fix: adjustment of Achievement Context * fix: introduce helper functions, refactor context * fix: type duplication * fix: reflect metadata --------- Co-authored-by: LomyW <[email protected]> Co-authored-by: LomyW <[email protected]> * feat: achievement is seen (#925) * feat: mutation for seen achievements * fix: change requests * feat: resolver values (#927) * feat: evaluation in resolver * fix: add record value to evaluation * fix: await achievements in resolver * fix: no await to get user achievements Co-authored-by: Daniel Henkel <[email protected]> * fix: merge parent branch * fix: update actions * fix: handle multiple metrics in evaluation value * add valueToAchieve to seed tiered achievements * adjust bucket creator context * fix: requested changes * fix no relation bucket context * fix: update generate achievement data * fix: achievement resolver (#930) * fix: get sequential achievements * fix: find user achievement * fix: preiod length is record value --------- Co-authored-by: Lucas <[email protected]> Co-authored-by: LucasFalkowsky <[email protected]> Co-authored-by: Daniel Henkel <[email protected]>
* add first draft of tables * first minor changes * add draft: aggregator, formula, bucket, metric * remove isAchieved * adjusted schema for achievements * add actionTaken() * comment: example import * add function to track events * add relation adjust formula return value * specific context * add migration * add metric and generic formula context * check for achievement action * track context * fix integration * adjust prop for bucket formula * add cached achievement template * register metrics * remove comment * add map for metric by name and by action * adjust for metrics map * add first bucket creators * add package swan * add relation resolution * add first draft to evaluate * add function to check for achievements * add achievements by group * add create user achievement * feat: backend implementation achievement resolver * adjusted evaluation * some drafts * adjust create sequential user achievement * add feature flag * add test actions and mutations * add achieved image to db * adjust next step index * fix: change requests * fix awarding user * seed db example type swan js parser * feat: evaluation of tiered achievements (#910) feat: filter bucket with achievement creation * feat: evaluation of streaks (#909) * feat: filter bucket with achievement creation * fix: branch update * fix: create time buckets returning buckets * feat: streak evaluation * fix: update streak with correct values * fix: merge clearing * fix: removed unnecessary checks and added comments * fix inject record value * fix: make it work * fix: change index generation for state handling * fix: work in change requests * feat: save and get by relation match and subcourse * add templates to seed db * fix: get next template on index * add metric and actions for student onboarding * trigger onboarding actions * fix: add values to context * fix: safe empty json in db * fix: set right achievement state * - add pupil onboarding, conducted match meetings - student conducted match meetings * fix: create achievement next step index * add metrics and action for pupil onboarding * add achievement mutation resolver * extend meeting action context * add data for regular learned streak * fix: change requests * fix: remove empty context * fix: added sampleContext and adjustet mutations * fix: requested changes * fix: update AchievementContext * fix: adjustment of Achievement Context * fix bucket by lecture start * prevent more events for one bucket * fix relation for buckets * fix bucket * get user achievement for create next * fix: introduce helper functions, refactor context * adjust bucketCreator for regular learned to weekly * fix: add condition for relation Co-authored-by: LomyW <[email protected]> * fix: remove test data, change requests * fix: reset achievedAt when condition not met * fix: type duplication * fix: reflect metadata * fix: reflect metadata * refactor of aggregators * review changes * rename streak aggregator * adjust streak data * sort desc * feat: refactor of aggregators (#926) * refactor of aggregators * review changes * rename streak aggregator * feat: relation context (#911) * feat: save and get by relation match and subcourse * fix: remove empty context * fix: added sampleContext and adjustet mutations * fix: update AchievementContext * fix: adjustment of Achievement Context * fix: introduce helper functions, refactor context * fix: type duplication * fix: reflect metadata --------- Co-authored-by: LomyW <[email protected]> Co-authored-by: LomyW <[email protected]> * feat: achievement is seen (#925) * feat: mutation for seen achievements * fix: change requests * feat: resolver values (#927) * feat: evaluation in resolver * fix: add record value to evaluation * fix: await achievements in resolver * fix: no await to get user achievements Co-authored-by: Daniel Henkel <[email protected]> * fix: merge parent branch * fix: update actions * fix: handle multiple metrics in evaluation value * add valueToAchieve to seed tiered achievements * adjust bucket creator context * fix: requested changes * fix no relation bucket context * add comments * fix: handle event relations in buckets * fix: adjust evaluateAchievement invocations * fix: update renaming of relationId to relation * fix: merge parent branch * fix: update generate achievement data * fix: achievement resolver (#930) * fix: get sequential achievements * fix: find user achievement * fix: in group order on achievement creation * fix: new relation types for achievement context * fix: recordValue as periodLength * feat: add comments for new features * feat: get inactive achievements * fix: only count lectures that were not declined * fix: current achievement for seqences * fix: change requests * fix: remove context type itteration from buckets * try to unify matches with global_matches (#934) * fix: templates by metrics * Feat: new resolvers (#933) * feat: by id and next step resolvers * fix: achievement field * fix: singular return on getAchievement Co-authored-by: Daniel Henkel <[email protected]> * fix: relation in resolver * fix: pass relation to evaluation --------- Co-authored-by: Daniel Henkel <[email protected]> * fix: change requests * fix: remove unnecessary unused code --------- Co-authored-by: LomyW <[email protected]> Co-authored-by: LomyW <[email protected]> Co-authored-by: Daniel Henkel <[email protected]>
* feature: add evaluate achievement unit tests
fix: only use template ID & relation to identify user_achievement
prisma/migrations/20231123075042_add_achievements_achieved_image/migration.sql
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice documentation! 💯
common/achievement/Readme.md
Outdated
| `id` | unique id | | ||
| `name` | displayed name of the template | | ||
| <div id="achievement_template_metrics">`metrics`</div> | used to identify all events related to a achievement template | | ||
| `templateFor` | discriminator to clarify a relation of an achievement template to 1. one match, 2. all matches, 3. one subcourse, 4. all subcourses or no relation | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure about no relation
?
export enum achievement_template_for_enum {
Course = "Course",
Global_Courses = "Global_Courses",
Match = "Match",
Global_Matches = "Global_Matches",
Global = "Global"
}"
common/achievement/Readme.md
Outdated
| `isSeen` | set true when a user has viewed an achieved achievement on their progress page | | ||
| `achievedAt` | timestamp set, if a achievements condition was met | | ||
| `recordValue` | record value on how long the longest streak was held up | | ||
| `context` | relations to matches, subcourses, pupils and students by their id | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not just the relationship, is it? It is the entirety of the matches, subcourses, students and pupils DATA that is needed for the initial submission of texts AND to make a reference to course / match / student etc
common/achievement/Readme.md
Outdated
| id | unique id | | ||
| userId | id of the user, that triggered the event | | ||
| metric | relation to dependent achievements data aggregation condition | | ||
| value | value of event used in the [aggregation](#data-aggregation) process, has a default of 1, but can also depict a certain duration | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure about the "default value 1"? I think it depends on what value is returned by the formula.
common/achievement/Readme.md
Outdated
| metric | relation to dependent achievements data aggregation condition | | ||
| value | value of event used in the [aggregation](#data-aggregation) process, has a default of 1, but can also depict a certain duration | | ||
| createdAt | timestamp from when the event was triggered | | ||
| action | the action triggered by this event | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| action | the action triggered by this event | | |
| action | the action that triggered the event. | |
| `create.ts` | functions to find certain achievements, get achievements, create achievements based on previously missing ones or to create an achievement as a follow-up achievement to a previous one | | ||
| `evaluate.ts` | functions to evaluate if an achievements conditions are met based on the [conditionDataAggregation](#conditionDataAggregation) of the related achievement_template | | ||
| `get.ts` | resolver functions to get all achievements, get certain achievements to be displayed as next steps, get achievements that are yet to be initialized, get achievements by their id and assemble the achievement data for the frontend | | ||
| `index.ts` | functions to initialize the evaluation process when an action was taken, cache metrics for events, and reward users when achievement conditions are met | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean by cache metrics for events
?
| `evaluate.ts` | functions to evaluate if an achievements conditions are met based on the [conditionDataAggregation](#conditionDataAggregation) of the related achievement_template | | ||
| `get.ts` | resolver functions to get all achievements, get certain achievements to be displayed as next steps, get achievements that are yet to be initialized, get achievements by their id and assemble the achievement data for the frontend | | ||
| `index.ts` | functions to initialize the evaluation process when an action was taken, cache metrics for events, and reward users when achievement conditions are met | | ||
| <div id="metric.ts">`metric.ts`</div> | functions to create metrics together with their related actions when building the project | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <div id="metric.ts">`metric.ts`</div> | functions to create metrics together with their related actions when building the project | | |
| <div id="metric.ts">`metric.ts`</div> | Collection of metrics and creation of metrics together with the associated actions when creating the project | |
| `index.ts` | functions to initialize the evaluation process when an action was taken, cache metrics for events, and reward users when achievement conditions are met | | ||
| <div id="metric.ts">`metric.ts`</div> | functions to create metrics together with their related actions when building the project | | ||
| `metrics.ts` | functions to register one or more metrics and to get metrics based on an action id | | ||
| `template.ts` | functions to get all templates presorted by group or metrics and to get templates with a certain metric | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `template.ts` | functions to get all templates presorted by group or metrics and to get templates with a certain metric | | |
| `template.ts` | Cached templates, sorted by groups or metrics, and to retrieve templates with a specific metric | |
|
||
### 2.1. Reward Action | ||
|
||
The achievement is linked to the pre-existing notification system and therefore triggers the `rewardActionTaken` function when ever the `actionTaken` function for a future notification is executed. This is working since achievements that have newly matched their conditions are announced as a notification, therefore naturally being linked to an action taken call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure about this description part, its not why the achievement systems works like this, not because of the new achieved achievement notification. It works because we use also the actions that are also used in the notifications system and we reuse this logic, and store actions in the metric.
This is working since achievements that have newly matched their conditions are announced as a notification, therefore naturally being linked to an action taken call
what was done:
a documentation for the backend has ben implemented inside the common/achievement fonder.