grim/youtrack-import

Convert the custom DebianBug and GnomeBug links to their absolute urls. Fixes YI-47
package trac
import (
"database/sql"
"keep.imfreedom.org/grim/youtrack-import/youtrack"
)
type component struct {
Name string `db:"name"`
Owner sql.NullString `db:"owner"`
Description sql.NullString `db:"description"`
}
func (e *environment) loadComponents(users map[string]*youtrack.User, unknownUser string) ([]youtrack.OwnedField, error) {
components := []component{}
err := e.db.Select(
&components,
`SELECT
distinct(t.component) AS name,
c.owner AS owner,
c.description AS description
FROM component c
FULL JOIN trac_pidgin.ticket t ON
c.name = t.component
ORDER BY t.component`,
)
ytSubsystem := make([]youtrack.OwnedField, len(components))
for idx, component := range components {
ytSubsystem[idx] = component.toYouTrack(users, unknownUser)
}
return ytSubsystem, err
}
func (c *component) toYouTrack(users map[string]*youtrack.User, unknownUser string) youtrack.OwnedField {
owner := mapUser(convertString(c.Owner), unknownUser, users)
return youtrack.OwnedField{
Value: c.Name,
Description: convertString(c.Description),
Owner: owner,
}
}