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

create channel parent/child relationship when importing parent #73

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions entityDumper/channelDataDumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ func processChannel(db *sql.DB, writer *bufio.Writer, channelLabel string,
tableData, printOptions)
log.Debug().Msg("finished print table order")

generateChannelChildLink(db, channelLabel, writer)

generateCacheCalculation(channelLabel, writer)

if !options.MetadataOnly {
Expand All @@ -243,6 +245,22 @@ func processChannel(db *sql.DB, writer *bufio.Writer, channelLabel string,

}

func generateChannelChildLink(db *sql.DB, channelLabel string, writer *bufio.Writer) {
childrenChannels := sqlUtil.ExecuteQueryWithResults(db, childChannelSql, channelLabel)
childChannelChildLabels := make([]string, 0)
for _, cChannel := range childrenChannels {
cLabel := fmt.Sprintf("'%v'", cChannel[0].Value)
fmt.Println(cLabel)
childChannelChildLabels = append(childChannelChildLabels, cLabel)
}

// recreate the relationship to child channels if any
if len(childChannelChildLabels) > 0 {
updateChildChannels := fmt.Sprintf("update rhnchannel set parent_channel = (select id from rhnchannel where label = '%s') where label in (%s);", channelLabel, strings.Join(childChannelChildLabels, ","))
writer.WriteString(updateChildChannels + "\n")
}
}

func generateCacheCalculation(channelLabel string, writer *bufio.Writer) {
// need to update channel modify since it's use to run repo metadata generation
updateChannelModifyDate := fmt.Sprintf("update rhnchannel set modified = current_timestamp where label = '%s';", channelLabel)
Expand Down
1 change: 1 addition & 0 deletions inter-server-sync.changes.rmateus.main
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- create channel parent/child relationship when importing parent
Loading