RocketChat/Rocket.Chat

View on GitHub
apps/meteor/server/models/raw/LivechatRooms.ts

Summary

Maintainability
F
1 mo
Test Coverage

File LivechatRooms.ts has 2479 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type {
    IOmnichannelRoom,
    RocketChatRecordDeleted,
    IOmnichannelRoomClosingInfo,
    DeepWritable,
Severity: Major
Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 6 days to fix

    LivechatRoomsRaw has 121 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class LivechatRoomsRaw extends BaseRaw<IOmnichannelRoom> implements ILivechatRoomsModel {
        constructor(db: Db, trash?: Collection<RocketChatRecordDeleted<IOmnichannelRoom>>) {
            super(db, 'room', trash);
        }
    
    
    Severity: Major
    Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 2 days to fix

      Function findAllNumberOfTransferredRooms has 116 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          findAllNumberOfTransferredRooms({
              start,
              end,
              departmentId,
              options = {},
      Severity: Major
      Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 4 hrs to fix

        Function getQueueMetrics has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getQueueMetrics({
                departmentId,
                agentId,
                includeOfflineAgents,
                options = {},
        Severity: Major
        Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 4 hrs to fix

          Function getAnalyticsMetricsBetweenDateWithMessages has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              getAnalyticsMetricsBetweenDateWithMessages(
                  t: string,
                  date: { gte: Date; lte: Date },
                  { departmentId }: { departmentId?: string } = {},
                  extraQuery: Document = {},
          Severity: Major
          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 2 hrs to fix

            Function getAnalyticsBetweenDate has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                getAnalyticsBetweenDate(date: { gte: Date; lte: Date }, { departmentId }: { departmentId?: string } = {}) {
                    return this.col.aggregate<Pick<IOmnichannelRoom, 'ts' | 'departmentId' | 'open' | 'servedBy' | 'metrics' | 'msgs' | 'onHold'>>(
                        [
                            {
                                $match: {
            Severity: Major
            Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 2 hrs to fix

              Function findRoomsByVisitorIdAndMessageWithCriteria has 61 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  findRoomsByVisitorIdAndMessageWithCriteria({
                      visitorId,
                      searchText,
                      open,
                      served,
              Severity: Major
              Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 2 hrs to fix

                Function findRoomsWithCriteria has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    findRoomsWithCriteria({
                        agents,
                        roomName,
                        departmentId,
                        open,
                Severity: Minor
                Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function findRoomsWithCriteria has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    findRoomsWithCriteria({
                        agents,
                        roomName,
                        departmentId,
                        open,
                Severity: Major
                Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 2 hrs to fix

                  Function getMACStatisticsBetweenDates has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async getMACStatisticsBetweenDates(start: Date, end: Date): Promise<MACStats[]> {
                          return this.col
                              .aggregate<MACStats>([
                                  {
                                      $match: {
                  Severity: Major
                  Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 2 hrs to fix

                    Function findPercentageOfAbandonedRooms has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async findPercentageOfAbandonedRooms({
                            start,
                            end,
                            departmentId,
                            onlyCount = false,
                    Severity: Major
                    Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 2 hrs to fix

                      Function getMACStatisticsForPeriod has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async getMACStatisticsForPeriod(period: string): Promise<MACStats[]> {
                              return this.col
                                  .aggregate<MACStats>([
                                      {
                                          $match: {
                      Severity: Major
                      Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 2 hrs to fix

                        Function saveRoomById has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async saveRoomById({
                                _id,
                                topic,
                                tags,
                                livechatData,
                        Severity: Minor
                        Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                          Function findAllAverageOfServiceTime has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              findAllAverageOfServiceTime({
                                  start,
                                  end,
                                  departmentId,
                                  onlyCount = false,
                          Severity: Minor
                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                            Function findAllAverageServiceTimeByAgents has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                findAllAverageServiceTimeByAgents({
                                    start,
                                    end,
                                    onlyCount = false,
                                    options = {},
                            Severity: Minor
                            Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                              Function countAllClosedChatsByDepartmentBetweenDate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  countAllClosedChatsByDepartmentBetweenDate({ start, end, departmentId }: { start: Date; end: Date; departmentId?: string }) {
                                      const match: Document = {
                                          $match: {
                                              t: 'l',
                                              open: { $exists: false },
                              Severity: Minor
                              Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                Function countAllOpenChatsByDepartmentBetweenDate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    countAllOpenChatsByDepartmentBetweenDate({ start, end, departmentId }: { start: Date; end: Date; departmentId?: string }) {
                                        const match: Document = {
                                            $match: {
                                                t: 'l',
                                                open: true,
                                Severity: Minor
                                Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                  Function findAllAverageWaitingTime has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      findAllAverageWaitingTime({
                                          start,
                                          end,
                                          departmentId,
                                          onlyCount = false,
                                  Severity: Minor
                                  Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                    Function calculateDurationTimingsBetweenDates has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        calculateDurationTimingsBetweenDates({ start, end, departmentId }: { start: Date; end: Date; departmentId?: string }) {
                                            const match: Document = {
                                                $match: {
                                                    't': 'l',
                                                    'ts': { $gte: new Date(start), $lte: new Date(end) },
                                    Severity: Minor
                                    Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                      Function findAllServiceTime has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          findAllServiceTime({
                                              start,
                                              end,
                                              departmentId,
                                              onlyCount = false,
                                      Severity: Minor
                                      Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                        Function findAllNumberOfAbandonedRooms has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            async findAllNumberOfAbandonedRooms({
                                                start,
                                                end,
                                                departmentId,
                                                onlyCount = false,
                                        Severity: Minor
                                        Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                          Function findAvailableSources has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              findAvailableSources() {
                                                  return this.col.aggregate([
                                                      {
                                                          $group: {
                                                              _id: 0,
                                          Severity: Minor
                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                            Function findAllAverageOfChatDurationTime has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                findAllAverageOfChatDurationTime({
                                                    start,
                                                    end,
                                                    departmentId,
                                                    onlyCount = false,
                                            Severity: Minor
                                            Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                              Function calculateReactionTimingsBetweenDates has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  calculateReactionTimingsBetweenDates({ start, end, departmentId }: { start: Date; end: Date; departmentId?: string }) {
                                                      const match: Document = {
                                                          $match: {
                                                              t: 'l',
                                                              ts: { $gte: new Date(start), $lte: new Date(end) },
                                              Severity: Minor
                                              Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                                Function calculateResponseTimingsBetweenDates has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                    calculateResponseTimingsBetweenDates({ start, end, departmentId }: { start: Date; end: Date; departmentId?: string }) {
                                                        const match: Document = {
                                                            $match: {
                                                                t: 'l',
                                                                ts: { $gte: new Date(start), $lte: new Date(end) },
                                                Severity: Minor
                                                Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                                  Function findAllRooms has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      findAllRooms({
                                                          start,
                                                          end,
                                                          answered,
                                                          departmentId,
                                                  Severity: Minor
                                                  Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                                    Function findAllServiceTimeByAgent has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                                    Open

                                                        findAllServiceTimeByAgent({
                                                            start,
                                                            end,
                                                            onlyCount = false,
                                                            options = {},
                                                    Severity: Minor
                                                    Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                                      Function saveRoomById has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                                      Open

                                                          async saveRoomById({
                                                              _id,
                                                              topic,
                                                              tags,
                                                              livechatData,
                                                      Severity: Minor
                                                      Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                                      Cognitive Complexity

                                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                      A method's cognitive complexity is based on a few simple rules:

                                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                      • Code is considered more complex for each "break in the linear flow of the code"
                                                      • Code is considered more complex when "flow breaking structures are nested"

                                                      Further reading

                                                      Function modelIndexes has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                                      Open

                                                          protected modelIndexes(): IndexDescription[] {
                                                              return [
                                                                  { key: { open: 1 }, sparse: true },
                                                                  { key: { departmentId: 1 }, sparse: true },
                                                                  { key: { 'metrics.chatDuration': 1 }, sparse: true },
                                                      Severity: Minor
                                                      Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                                        Function countAllOpenChatsByAgentBetweenDate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                        Open

                                                            countAllOpenChatsByAgentBetweenDate({ start, end, departmentId }: { start: Date; end: Date; departmentId?: string }) {
                                                                const match: Document = {
                                                                    $match: {
                                                                        't': 'l',
                                                                        'servedBy.username': { $exists: true },
                                                        Severity: Minor
                                                        Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 1 hr to fix

                                                          Function findAllRooms has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              findAllRooms({
                                                                  start,
                                                                  end,
                                                                  answered,
                                                                  departmentId,
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 55 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function findPercentageOfAbandonedRooms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              async findPercentageOfAbandonedRooms({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 25 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function findAllAverageOfChatDurationTime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              findAllAverageOfChatDurationTime({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 25 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function getQueueMetrics has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              getQueueMetrics({
                                                                  departmentId,
                                                                  agentId,
                                                                  includeOfflineAgents,
                                                                  options = {},
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 25 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function findAllServiceTime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              findAllServiceTime({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 25 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function findRoomsByVisitorIdAndMessageWithCriteria has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              findRoomsByVisitorIdAndMessageWithCriteria({
                                                                  visitorId,
                                                                  searchText,
                                                                  open,
                                                                  served,
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 25 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function findAllNumberOfAbandonedRooms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              async findAllNumberOfAbandonedRooms({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 25 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function findAllAverageWaitingTime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              findAllAverageWaitingTime({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts - About 25 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              calculateResponseTimingsBetweenDates({ start, end, departmentId }: { start: Date; end: Date; departmentId?: string }) {
                                                                  const match: Document = {
                                                                      $match: {
                                                                          t: 'l',
                                                                          ts: { $gte: new Date(start), $lte: new Date(end) },
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 day to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 970..1011

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 307.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              calculateReactionTimingsBetweenDates({ start, end, departmentId }: { start: Date; end: Date; departmentId?: string }) {
                                                                  const match: Document = {
                                                                      $match: {
                                                                          t: 'l',
                                                                          ts: { $gte: new Date(start), $lte: new Date(end) },
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 day to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 927..968

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 307.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 6 locations. Consider refactoring.
                                                          Open

                                                              findAllAverageOfServiceTime({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 5 other locations - About 4 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 214..268
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 270..341
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 343..397
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 399..455
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 514..568

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 115.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 6 locations. Consider refactoring.
                                                          Open

                                                              async findPercentageOfAbandonedRooms({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 5 other locations - About 4 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 214..268
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 343..397
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 399..455
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 514..568
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1057..1114

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 115.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 6 locations. Consider refactoring.
                                                          Open

                                                              async findAllNumberOfAbandonedRooms({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 5 other locations - About 4 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 270..341
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 343..397
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 399..455
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 514..568
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1057..1114

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 115.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 6 locations. Consider refactoring.
                                                          Open

                                                              findAllAverageWaitingTime({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 5 other locations - About 4 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 214..268
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 270..341
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 343..397
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 514..568
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1057..1114

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 115.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 6 locations. Consider refactoring.
                                                          Open

                                                              findAllServiceTime({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 5 other locations - About 4 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 214..268
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 270..341
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 343..397
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 399..455
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1057..1114

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 115.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 6 locations. Consider refactoring.
                                                          Open

                                                              findAllAverageOfChatDurationTime({
                                                                  start,
                                                                  end,
                                                                  departmentId,
                                                                  onlyCount = false,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 5 other locations - About 4 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 214..268
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 270..341
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 399..455
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 514..568
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1057..1114

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 115.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              findAllAverageServiceTimeByAgents({
                                                                  start,
                                                                  end,
                                                                  onlyCount = false,
                                                                  options = {},
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 3 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1343..1393

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 103.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              findAllServiceTimeByAgent({
                                                                  start,
                                                                  end,
                                                                  onlyCount = false,
                                                                  options = {},
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 3 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1395..1450

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 103.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              findByVisitorId(visitorId: string, options: FindOptions<IOmnichannelRoom>, extraQuery: Filter<IOmnichannelRoom> = {}) {
                                                                  const query: Filter<IOmnichannelRoom> = {
                                                                      't': 'l',
                                                                      'v._id': visitorId,
                                                                      ...extraQuery,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 2 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1125..1132

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 89.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              findPaginatedByVisitorId(visitorId: string, options: FindOptions<IOmnichannelRoom>, extraQuery: Filter<IOmnichannelRoom> = {}) {
                                                                  const query: Filter<IOmnichannelRoom> = {
                                                                      't': 'l',
                                                                      'v._id': visitorId,
                                                                      ...extraQuery,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 2 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1116..1123

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 89.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                  if (closedAt) {
                                                                      query.closedAt = {};
                                                                      if (closedAt.start) {
                                                                          query.closedAt.$gte = new Date(closedAt.start);
                                                                      }
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 2 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1273..1281

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 87.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                  if (createdAt) {
                                                                      query.ts = {};
                                                                      if (createdAt.start) {
                                                                          query.ts.$gte = new Date(createdAt.start);
                                                                      }
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 2 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1282..1290

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 87.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 3 locations. Consider refactoring.
                                                          Open

                                                              getConversationsByTags(
                                                                  _start: Date,
                                                                  _end: Date,
                                                                  _sort: Record<string, 1 | -1>,
                                                                  _extraQuery: Filter<IOmnichannelRoom>,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 2 other locations - About 2 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2668..2675
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2686..2693

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 75.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 3 locations. Consider refactoring.
                                                          Open

                                                              getConversationsByAgents(
                                                                  _start: Date,
                                                                  _end: Date,
                                                                  _sort: Record<string, 1 | -1>,
                                                                  _extraQuery: Filter<IOmnichannelRoom>,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 2 other locations - About 2 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2668..2675
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2677..2684

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 75.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 3 locations. Consider refactoring.
                                                          Open

                                                              getConversationsByDepartment(
                                                                  _start: Date,
                                                                  _end: Date,
                                                                  _sort: Record<string, 1 | -1>,
                                                                  _extraQuery: Filter<IOmnichannelRoom>,
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 2 other locations - About 2 hrs to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2677..2684
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2686..2693

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 75.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                          {
                                                                              $group: {
                                                                                  _id: null,
                                                                                  sources: {
                                                                                      $push: {
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2470..2491

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 74.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                          {
                                                                              $group: {
                                                                                  _id: null,
                                                                                  sources: {
                                                                                      $push: {
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2532..2553

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 74.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 3 locations. Consider refactoring.
                                                          Open

                                                                  const project = {
                                                                      $project: {
                                                                          _id: { $ifNull: ['$_id.departmentId', null] },
                                                                          averageServiceTimeInSeconds: {
                                                                              $ceil: { $cond: [{ $eq: ['$rooms', 0] }, 0, { $divide: ['$allServiceTime', '$rooms'] }] },
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 2 other locations - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 373..380
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 429..438

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 67.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 3 locations. Consider refactoring.
                                                          Open

                                                                  const project = {
                                                                      $project: {
                                                                          _id: { $ifNull: ['$_id.departmentId', null] },
                                                                          averageChatDurationTimeInSeconds: {
                                                                              $ceil: { $cond: [{ $eq: ['$rooms', 0] }, 0, { $divide: ['$chatsDuration', '$rooms'] }] },
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 2 other locations - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 429..438
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1090..1097

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 67.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 3 locations. Consider refactoring.
                                                          Open

                                                                  const project = {
                                                                      $project: {
                                                                          _id: { $ifNull: ['$_id.departmentId', null] },
                                                                          averageWaitingTimeInSeconds: {
                                                                              $ceil: {
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 2 other locations - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 373..380
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1090..1097

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 67.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                              $match: {
                                                                                  t,
                                                                                  ts: {
                                                                                      $gte: new Date(date.gte), // ISO Date, ts >= date.gte
                                                                                      $lte: new Date(date.lte), // ISODate, ts <= date.lte
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2088..2096

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 67.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                  const query: Filter<IOmnichannelRoom> = {
                                                                      t,
                                                                      ts: {
                                                                          $gte: new Date(date.gte), // ISO Date, ts >= date.gte
                                                                          $lte: new Date(date.lte), // ISODate, ts <= date.lte
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2113..2121

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 67.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              saveCRMDataByRoomId(roomId: string, crmData: unknown) {
                                                                  const query: Filter<IOmnichannelRoom> = {
                                                                      _id: roomId,
                                                                      t: 'l',
                                                                  };
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2305..2317

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 65.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              changeDepartmentIdByRoomId(roomId: string, departmentId: string) {
                                                                  const query: Filter<IOmnichannelRoom> = {
                                                                      _id: roomId,
                                                                      t: 'l',
                                                                  };
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2319..2331

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 65.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                  const match: Document = {
                                                                      $match: {
                                                                          't': 'l',
                                                                          'servedBy._id': { $exists: true },
                                                                          'metrics.serviceTimeDuration': { $exists: true },
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1406..1416

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 63.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                  const match: Document = {
                                                                      $match: {
                                                                          't': 'l',
                                                                          'servedBy._id': { $exists: true },
                                                                          'metrics.serviceTimeDuration': { $exists: true },
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1354..1364

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 63.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                  const group: Document = {
                                                                      $group: {
                                                                          _id: {
                                                                              _id: null,
                                                                              departmentId: '$departmentId',
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 363..372

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 58.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                  const group: Document = {
                                                                      $group: {
                                                                          _id: {
                                                                              _id: null,
                                                                              departmentId: '$departmentId',
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 1 hr to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 419..428

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 58.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              getConversationsBySource(_start: Date, _end: Date, _extraQuery: Filter<IOmnichannelRoom>): AggregationCursor<ReportResult> {
                                                                  throw new Error('Method not implemented.');
                                                              }
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 55 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2664..2666

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 54.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              getConversationsByStatus(_start: Date, _end: Date, _extraQuery: Filter<IOmnichannelRoom>): AggregationCursor<ReportResult> {
                                                                  throw new Error('Method not implemented.');
                                                              }
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 55 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2660..2662

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 54.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 3 locations. Consider refactoring.
                                                          Open

                                                              getTotalConversationsWithoutDepartmentBetweenDates(_start: Date, _end: Date, _extraQuery: Filter<IOmnichannelRoom>): Promise<number> {
                                                                  throw new Error('Method not implemented.');
                                                              }
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 2 other locations - About 50 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2695..2697
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2699..2701

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 52.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 3 locations. Consider refactoring.
                                                          Open

                                                              getConversationsWithoutTagsBetweenDate(_start: Date, _end: Date, _extraQuery: Filter<IOmnichannelRoom>): Promise<number> {
                                                                  throw new Error('Method not implemented.');
                                                              }
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 2 other locations - About 50 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2699..2701
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2703..2705

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 52.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 3 locations. Consider refactoring.
                                                          Open

                                                              getTotalConversationsWithoutAgentsBetweenDate(_start: Date, _end: Date, _extraQuery: Filter<IOmnichannelRoom>): Promise<number> {
                                                                  throw new Error('Method not implemented.');
                                                              }
                                                          Severity: Major
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 2 other locations - About 50 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2695..2697
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2703..2705

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 52.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                  const group = {
                                                                      $group: {
                                                                          _id: { _id: '$servedBy._id', username: '$servedBy.username' },
                                                                          chats: { $sum: 1 },
                                                                          serviceTimeDuration: { $sum: '$metrics.serviceTimeDuration' },
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 50 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1365..1371

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 52.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                  const group = {
                                                                      $group: {
                                                                          _id: { _id: '$servedBy._id', username: '$servedBy.username' },
                                                                          chats: { $sum: 1 },
                                                                          serviceTimeDuration: { $sum: '$metrics.serviceTimeDuration' },
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 50 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1417..1423

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 52.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Identical blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                          if (value) {
                                                                              setData[`livechatData.${key}`] = value;
                                                                          } else {
                                                                              unsetData[`livechatData.${key}`] = 1;
                                                                          }
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 50 mins to fix
                                                          apps/meteor/server/models/raw/LivechatVisitors.ts on lines 338..342

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 51.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                          {
                                                                              $group: {
                                                                                  _id: {
                                                                                      source: {
                                                                                          $ifNull: ['$source.alias', '$source.type'],
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 45 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2455..2469

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 50.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                                          {
                                                                              $group: {
                                                                                  _id: {
                                                                                      source: {
                                                                                          $ifNull: ['$source.alias', '$source.type'],
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 45 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 2517..2531

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 50.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              setVisitorInactivityInSecondsById(roomId: string, visitorInactivity: number) {
                                                                  const query = {
                                                                      _id: roomId,
                                                                  };
                                                                  const update = {
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 40 mins to fix
                                                          apps/meteor/ee/server/models/raw/LivechatRooms.ts on lines 221..232

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 48.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              setPdfTranscriptFileIdById(rid: string, fileId: string) {
                                                                  return this.updateOne(
                                                                      {
                                                                          _id: rid,
                                                                      },
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 40 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1452..1454

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 48.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              setDepartmentByRoomId(roomId: string, departmentId: string) {
                                                                  return this.updateOne({ _id: roomId }, { $set: { departmentId } });
                                                              }
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 40 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1567..1576

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 48.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              unsetAutoTransferOngoingById(roomId: string) {
                                                                  const query = {
                                                                      _id: roomId,
                                                                  };
                                                                  const update = {
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 40 mins to fix
                                                          apps/meteor/server/models/raw/LivechatDepartment.ts on lines 203..215

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 48.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              findByVisitorIdAndAgentId(
                                                                  visitorId?: string,
                                                                  agentId?: string,
                                                                  options: FindOptions<IOmnichannelRoom> = {},
                                                                  extraQuery: Filter<IOmnichannelRoom> = {},
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 35 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1932..1947

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 47.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              findOpenByVisitorTokenAndDepartmentId(
                                                                  visitorToken: string,
                                                                  departmentId: string,
                                                                  options: FindOptions<IOmnichannelRoom> = {},
                                                                  extraQuery: Filter<IOmnichannelRoom> = {},
                                                          Severity: Minor
                                                          Found in apps/meteor/server/models/raw/LivechatRooms.ts and 1 other location - About 35 mins to fix
                                                          apps/meteor/server/models/raw/LivechatRooms.ts on lines 1959..1973

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 47.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          There are no issues that match your filters.

                                                          Category
                                                          Status