getContentFromAdditionalResource gets domain_additional_resource by uuid, get the field content if it exists, otherwise get the field compressed_content. old content field: content new centent field: compressed_content
(domainUUID string, db *gorm.DB)
| 599 | // old content field: content |
| 600 | // new centent field: compressed_content |
| 601 | func getContentFromAdditionalResource(domainUUID string, db *gorm.DB) (*metadbmodel.DomainAdditionalResource, error) { |
| 602 | var dbItems []metadbmodel.DomainAdditionalResource |
| 603 | result := db.Select("content").Where(map[string]interface{}{"domain": domainUUID}).Where("content != ''").Find(&dbItems) |
| 604 | if result.Error != nil { |
| 605 | return nil, result.Error |
| 606 | } |
| 607 | |
| 608 | if result.RowsAffected == 0 { |
| 609 | result = db.Select("compressed_content").Where(map[string]interface{}{"domain": domainUUID}).Find(&dbItems) |
| 610 | if result.Error != nil { |
| 611 | return nil, result.Error |
| 612 | } |
| 613 | if result.RowsAffected == 0 { |
| 614 | return nil, nil |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | return &dbItems[0], nil |
| 619 | } |
| 620 | |
| 621 | func (c *Cloud) appendCloudTags(resource model.Resource, additionalResource model.AdditionalResource) model.Resource { |
| 622 | chostCloudTags := additionalResource.CHostCloudTags |
no test coverage detected