// Order messages ascending by ID for presentation
342281
func getUIMsgs(ctx context.Context, g *globals.Context, convID chat1.ConversationID,
	uid gregor1.UID, msgs []chat1.MessageUnboxed) (uiMsgs []chat1.UIMessage) {
	for i := len(msgs) - 1; i >= 0; i-- {
		msg := msgs[i]
		uiMsg := utils.PresentMessageUnboxed(ctx, g, msg, uid, convID)
		uiMsgs = append(uiMsgs, uiMsg)
	}
	return uiMsgs
}
932819
func (b *Builder) OrderBy(orderBy string) *Builder {
	b.orderBy = orderBy
	return b
}
853650
func (m *Message) AddDatum(ID string, Name string, Value string) {
	if m.StructuredData == nil {
		m.StructuredData = []StructuredData{}
	}
	for i, sd := range m.StructuredData {
		if sd.ID == ID {
			sd.Parameters = append(sd.Parameters, SDParam{Name: Name, Value: Value})
			m.StructuredData[i] = sd
			return
		}
	}

	m.StructuredData = append(m.StructuredData, StructuredData{
		ID: ID,
		Parameters: []SDParam{
			SDParam{
				Name:  Name,
				Value: Value,
			},
		},
	})
}
1170581
func NewFormattedMessage(p level.Priority, base string, args ...interface{}) Composer {
	m := &formatMessenger{
		base: base,
		args: args,
	}
	_ = m.SetPriority(p)

	return m
}
48190
func (c *Context) EditMessagesWithEventID(eventID string, fromState string, text string, kb InlineKeyboard) (edited int, err error) {
	var messages []OutgoingMessage
	f := bson.M{"botid": c.Bot().ID, "eventid": eventID}
	if fromState != "" {
		f["inlinekeyboardmarkup.state"] = fromState
	}

	//update MAX_MSGS_TO_UPDATE_WITH_EVENTID last bot messages
	c.db.C("messages").Find(f).Sort("-_id").Limit(MaxMsgsToUpdateWithEventID).All(&messages)
	for _, message := range messages {
		err = c.EditMessageTextAndInlineKeyboard(&message, fromState, text, kb)
		if err != nil {
			c.Log().WithError(err).WithField("eventid", eventID).Error("EditMessagesWithEventID")
		} else {
			edited++
		}
	}
	return edited, err
}
441383
func (conn *FakeVTGateConn) MessageAckKeyspaceIds(ctx context.Context, keyspace string, name string, idKeyspaceIDs []*vtgatepb.IdKeyspaceId) (int64, error) {
	panic("not implemented")
}
200695
func (o Orderer) ID() string {
	return fmt.Sprintf("%s.%s", o.Organization, o.Name)
}
1036840
func ListMessages(c *messagebird.Client, conversationID string, options *ListOptions) (*MessageList, error) {
	query := paginationQuery(options)
	uri := fmt.Sprintf("%s/%s/%s?%s", path, conversationID, messagesPath, query)

	messageList := &MessageList{}
	if err := request(c, messageList, http.MethodGet, uri, nil); err != nil {
		return nil, err
	}

	return messageList, nil
}
706873
func (vtg *VTGate) MessageAckKeyspaceIds(ctx context.Context, keyspace string, name string, idKeyspaceIDs []*vtgatepb.IdKeyspaceId) (int64, error) {
	startTime := time.Now()
	ltt := topoproto.TabletTypeLString(topodatapb.TabletType_MASTER)
	statsKey := []string{"MessageAckKeyspaceIds", keyspace, ltt}
	defer vtg.timings.Record(statsKey, startTime)

	for _, idKeyspaceID := range idKeyspaceIDs {
		if _, err := sqltypes.NewValue(idKeyspaceID.Id.Type, idKeyspaceID.Id.Value); err != nil {
			return 0, formatError(err)
		}
	}

	count, err := vtg.resolver.MessageAckKeyspaceIds(ctx, keyspace, name, idKeyspaceIDs)
	return count, formatError(err)
}
1190935
func (m *Message) MessageSig() (string, int64) {
	return strconv.Itoa(m.ID), m.Chat.ID
}
1315200
func (mg *MailgunImpl) ListEvents(opts *ListEventOptions) *EventIterator {
	req := newHTTPRequest(generateApiUrl(mg, eventsEndpoint))
	if opts != nil {
		if opts.Limit > 0 {
			req.addParameter("limit", fmt.Sprintf("%d", opts.Limit))
		}
		if opts.Compact {
			req.addParameter("pretty", "no")
		}
		if opts.ForceAscending {
			req.addParameter("ascending", "yes")
		} else if opts.ForceDescending {
			req.addParameter("ascending", "no")
		}
		if !opts.Begin.IsZero() {
			req.addParameter("begin", formatMailgunTime(opts.Begin))
		}
		if !opts.End.IsZero() {
			req.addParameter("end", formatMailgunTime(opts.End))
		}
		if opts.Filter != nil {
			for k, v := range opts.Filter {
				req.addParameter(k, v)
			}
		}
	}
	url, err := req.generateUrlWithParameters()
	return &EventIterator{
		mg:       mg,
		Response: events.Response{Paging: events.Paging{Next: url, First: url}},
		err:      err,
	}
}
1054566
func (m *Message) UpdateEventsID(db *mgo.Database, eventID ...string) error {
	m.EventID = append(m.EventID, eventID...)
	f := bson.M{"botid": m.BotID}
	if m.InlineMsgID != "" {
		f["inlinemsgid"] = m.InlineMsgID
	} else {
		f["chatid"] = m.ChatID
		f["msgid"] = m.MsgID
	}
	return db.C("messages").Update(f, bson.M{"$addToSet": bson.M{"eventid": bson.M{"$each": eventID}}})
}
713764
func (buildRes BuildRunResultsModel) OrderedResults() []StepRunResultsModel {
	results := make([]StepRunResultsModel, buildRes.ResultsCount())
	unorderedResults := buildRes.unorderedResults()
	for _, result := range unorderedResults {
		results[result.Idx] = result
	}
	return results
}
1250829
func NewScriptSort(script, typ string) ScriptSort {
	return ScriptSort{
		script:    script,
		typ:       typ,
		ascending: true,
		params:    make(map[string]interface{}),
	}
}
917984
func (statement *Statement) OrderBy(order string) *Statement {
	if len(statement.OrderStr) > 0 {
		statement.OrderStr += ", "
	}
	statement.OrderStr += order
	return statement
}
208918
func (n *Network) ordererUserCryptoDir(o *Orderer, user, cryptoMaterialType string) string {
	org := n.Organization(o.Organization)
	Expect(org).NotTo(BeNil())

	return n.userCryptoDir(org, "ordererOrganizations", user, cryptoMaterialType)
}
356026
func (s *ScoreSort) Order(ascending bool) *ScoreSort {
	s.ascending = ascending
	return s
}