MCPcopy Create free account
hub / github.com/apache/devlake / createOrUpdateAccount

Method createOrUpdateAccount

backend/plugins/customize/service/service.go:269–293  ·  view source on GitHub ↗

createOrUpdateAccount creates or updates an account based on the provided name. It returns the account ID and an error if any occurred.

(accountName string, rawDataParams string)

Source from the content-addressed store, hash-verified

267// createOrUpdateAccount creates or updates an account based on the provided name.
268// It returns the account ID and an error if any occurred.
269func (s *Service) createOrUpdateAccount(accountName string, rawDataParams string) (string, errors.Error) {
270 if accountName == "" {
271 return "", nil // Return empty ID if name is empty, no error needed here.
272 }
273 now := time.Now()
274 accountId := fmt.Sprintf("csv:CsvAccount:0:%s", accountName)
275 account := &crossdomain.Account{
276 DomainEntity: domainlayer.DomainEntity{
277 Id: accountId,
278 NoPKModel: common.NoPKModel{
279 RawDataOrigin: common.RawDataOrigin{
280 RawDataParams: rawDataParams,
281 },
282 },
283 },
284 FullName: accountName,
285 UserName: accountName,
286 CreatedDate: &now, // FIXME: will update created_date if already exists. to debug, using created_at instead
287 }
288 err := s.dal.CreateOrUpdate(account)
289 if err != nil {
290 return "", errors.Default.Wrap(err, fmt.Sprintf("failed to create or update account for %s", accountName))
291 }
292 return accountId, nil
293}
294
295// getStringField extracts a string field from a record map.
296// If required is true, it returns an error if the field is missing, nil, empty, or not a string.

Callers 6

issueHandlerFactoryMethod · 0.95
qaApiHandlerMethod · 0.95
qaTestCaseHandlerMethod · 0.95
issueChangelogHandlerMethod · 0.95
issueWorklogHandlerMethod · 0.95

Calls 2

WrapMethod · 0.80
CreateOrUpdateMethod · 0.65

Tested by

no test coverage detected