Skip to content
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

Remove feedbackcount col #1428

Merged
merged 21 commits into from
Jan 27, 2025
Merged

Remove feedbackcount col #1428

merged 21 commits into from
Jan 27, 2025

Conversation

Veikkosuhonen
Copy link
Member

@Veikkosuhonen Veikkosuhonen commented Jan 8, 2025

Implements #1227

Fairly big fix and refactor so the feedbackCount of an FBT is now stored in one place, the data JSONB column of the corresponding Summary.

There are no visible changes other than an elusive bug getting fixed.

Database changes

  • The feedback_count column of table feedback_targets is dropped

Bugs fixed

The feedback count of a course had different values in some places, since some views used summary.data.feedbackCount and some used the dropped feedbackTarget.feedbackCount

Testing

Automatic tests were updated to reflect the fix. A new test was added for a common bug case where the feedbackCounts would differ.

Implementation details...

The corresponding summaries of a course are now always updated when feedback is created or deleted, so they stay up to date. Cached values are also updated.

userCreated: true feedbackTargets now have summaries created for them, when they are created, and when the summary cron runs.

New files were written in typescript and some existing files were converted.

package-lock.json has a lot of changes (so the insertions - additions looks scary) - I will try to get rid of that.

@Veikkosuhonen Veikkosuhonen force-pushed the remove-feedbackcount-col branch from f33044f to 0a7f368 Compare January 8, 2025 15:11
@Veikkosuhonen Veikkosuhonen added refactor no visible changez bug norppa is broken labels Jan 13, 2025
@Veikkosuhonen Veikkosuhonen marked this pull request as ready for review January 13, 2025 21:53
@Veikkosuhonen Veikkosuhonen linked an issue Jan 14, 2025 that may be closed by this pull request
3 tasks
@@ -250,6 +250,7 @@ CourseUnit.hasMany(Summary, { sourceKey: 'groupId', foreignKey: 'entityId', as:

Summary.belongsTo(FeedbackTarget, { foreignKey: 'feedbackTargetId', as: 'feedbackTarget' })
FeedbackTarget.hasOne(Summary, { foreignKey: 'feedbackTargetId', as: 'summary' })
FeedbackTarget.hasMany(Summary, { foreignKey: 'feedbackTargetId', as: 'summaries' })
Copy link
Collaborator

Choose a reason for hiding this comment

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

hasOne ja hasMany molemmat

Copy link
Member Author

Choose a reason for hiding this comment

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

Joo, tuntuu typerältä mutta ajattelin näin kuitenkin. Yleensä feedbackTargettiin halutaan yksi 'summary' mukaan, ja nyt niiden summaryiden datat on samat joten ei väliä, mikä summary tulee mukaan.

Jossain kohti saatetaan kuitenkin haluta kaikki 'summaries', joka on tietokannan kannalta se oikea relaatio.

Eli nyt tuo alias 'summary' vain tekee kyselyn mukavemmaksi, kun ei tarvitse hakea listaa 'summaries' ja valita listalta yhtä.

@@ -63,6 +63,7 @@ Summary.init(
feedbackTargetId: {
type: INTEGER,
allowNull: true,
unique: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tää pois?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hyvä huomio, poistan

@@ -114,7 +119,7 @@ const getInterimFeedbackTargets = async (parentId, user) => {
as: 'courseRealisation',
required: true,
},
{
/*{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kommentti miks tää kommentoitu, varmistus ettei jossain oo viitattu näihin?

Copy link
Member Author

Choose a reason for hiding this comment

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

Joo, varmistin ettei käytetä missään.

Poistan kommentin.

@@ -100,7 +100,7 @@ const buildSummariesForPeriod = async ({
// Get all the feedback data and associated entities for this period. Then the rest is done JS side.
const feedbackTargets = await FeedbackTarget.findAll({
where: {
userCreated: false, // Custom feedbacks may cause issues and dont contribute to stats anyways.
// userCreated: false, // Custom feedbacks may cause issues and dont contribute to stats anyways.
Copy link
Collaborator

@AstaLW AstaLW Jan 22, 2025

Choose a reason for hiding this comment

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

Miksi kommenteissa. Jotta välipalautekohteet tulee summariesiin? Nuo loopataan nyt kaikissa tän tiedoston yhteenvetolaskuissa, pitäs siellä ehkä suodattaa pois. Vaikkei varmaan vaikutusta kun ei yhteenvetokysymyksiä, mutta turhaa.

Copy link
Member Author

Choose a reason for hiding this comment

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

Pitää varmistaa että välipalautteille luodaan summaryt, koska niistä saadaan feedbackCount tieto niille. Croni poistaa kaikki summaryt joten sen myös pitää luoda ne.

Mutta joo pitäisi ehkä filtteröidä niin että välipalautteiden statsit ei mene "ylöspäin" CU ja organisaatiostatseihin.

feedbackTargets: _.uniqBy(
feedbackTargets.filter(fbt => !fbt.userCreated),
'feedbackTargetId'
),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tää pitäs varmaan lisätä useampaan kohtaan (jos etsii kohdat missä 'feedbackTargets: _.uniqBy(feedbackTargets, 'feedbackTargetId')' eli courseRealisationSummaries ja courseUnitSummaries ja courseUnitGroupSummaries

Pitäskö tehdä lista 'basicFeedbackTargets' tms missä vaan noi userCreated false ja antaa se noille ?

Ja mitenhän toi feedbackTargetsSummaries jota käytetään sit muiden summaryiden laskennassa. pitäskö siitäkin olla basic versio, jota käytetään muissa paitsi sit ihan lopun ft-summary tallennuksessa, eli noita välipalautteita ei tarvittas missään muualla?

Copy link
Member Author

Choose a reason for hiding this comment

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

Päivitin sen tälleen että muiden summaryiden laskennassa käytetään basicFeedbackTargetSummaries joista suodatettu userCreated

@Veikkosuhonen Veikkosuhonen merged commit 9a61257 into master Jan 27, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug norppa is broken refactor no visible changez
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the denormalized feedbackCount from FBT
2 participants